Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. require "init.php";
  4. $username = $_POST["username"];
  5. $password = $_POST["password"];
  6. //$username = "sdf";
  7. //$password = "sdf";
  8.  
  9.  
  10. if($username == '' || $password == ''){
  11. echo 'Please dont leave any fields empty';
  12. }else{
  13. require_once('init.php');
  14.  
  15. $sql = "SELECT * FROM user WHERE username='$username'";
  16.  
  17. $check = mysqli_fetch_array(mysqli_query($con,$sql));
  18.  
  19. if(isset($check)){
  20. echo 'Sorry that name is already taken';
  21. }else{
  22.  
  23.  
  24. $sql = "INSERT INTO `user` (`username`,`password`) VALUES ('".$username."', '".$password."');";
  25. if(!mysqli_query($con, $sql)){
  26. echo '{"message":"Unable to save the data to the database."}';
  27. }
  28. }
  29. }
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement