frostyfire

php -registration

Aug 21st, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. <?php
  2.  
  3. $con = mysqli_connect('localhost', 'admin', 'admin', 'carnival_db');
  4.  
  5. if(mysqli_connect_errno())
  6. {
  7. echo "1: conection failed";
  8. exit();
  9. }
  10.  
  11. $username = $_POST["name"];
  12. $password = $_POST["password"];
  13. $house = $_POST["house"];
  14.  
  15.  
  16. $namecheckquery = "SELECT username FROM players WHERE username ='".$username."'";
  17.  
  18.  
  19. $namecheck = mysqli_query($con, $namecheckquery) or die("2: name check query failed");
  20.  
  21. if(mysqli_num_rows($namecheck) > 0)
  22. {
  23.  
  24. echo "3: name already exist";
  25. }
  26.  
  27. $salt = "\$5\$rounds=5000\$"."steamedhams".$username."\$";
  28. $hash = crypt($password, $salt);
  29.  
  30. $insertuserquery = "INSERT INTO players (username, hash, salt, house) VALUES ('".$username."', '".$hash."', '".$salt."', '".$house."')";
  31.  
  32.  
  33. mysqli_query($con, $insertuserquery) or die ("4: insert player query failed");
  34.  
  35. echo("0");
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment