Advertisement
MinecraftRocks999

Untitled

Jan 11th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2. $username = $_POST['username'];
  3. $password = $_POST['password'];
  4. $email = $_POST['email'];
  5. $fullname = $_POST['name'];
  6. $pmcUsername = $_POST['pmc'];
  7.  
  8. $mysqli = new mysqli(-snip-);
  9.  
  10. $username = $mysqli->real_escape_string($username);
  11. $password = $mysqli->real_escape_string($password);
  12. $email = $mysqli->real_escape_string($email);
  13. $fullname = $mysqli->real_escape_string($fullname);
  14. $pmcUsername = $mysqli->real_escape_string($pmcUsername);
  15.  
  16. if ($mysqli->connect_error) {
  17. die('Error : ('. $mysqli->connect_errno .') '. $mysqli->connect_error);
  18. }
  19.  
  20. $result = $mysqli->query("SELECT username, email, pmcUsername FROM `users`");
  21.  
  22. if(!$result){
  23. die('There was an error running the query [' . $mysqli->error . ']');
  24. }
  25.  
  26. $hasFound = false;
  27. while($row = $result->fetch_assoc()){
  28. if ($row['username']==$username) {
  29. $hasFound = true;
  30. }
  31. if ($row['email']==$email) {
  32. $hasFound = true;
  33. }
  34. if ($row['pmcUsername']==$pmcUsername) {
  35. $hasFound = true;
  36. }
  37. }
  38. $result->free();
  39.  
  40. if ($username.isSet()) {
  41. $hasFound = true;
  42. }
  43. if ($password.isSet()) {
  44. $hasFound = true;
  45. }
  46. if ($email.isSet()) {
  47. $hasFound = true;
  48. }
  49. if ($fullname.isSet()) {
  50. $hasFound = true;
  51. }
  52. if ($pmcUsername.isSet()) {
  53. $hasFound = true;
  54. }
  55.  
  56. if ($hasFound==false) {
  57. $salt = uniqid($username, true);
  58. $encryptedPassword = crypt($password, $salt);
  59. $datentime = $mysqli->real_escape_string(date('Y/m/d H:i:s'));
  60. $result = $mysqli->query("INSERT INTO `users` (`username`, `password`, `email`, `name`, `accessToken`, `pmcUsername`, `minecraftUsername`, `registeredTime`) VALUES ('".$username."', '".$encryptedPassword."', '".$email."', '".$fullname."', '', '".$pmcUsername."', '', '".$datentime."')");
  61. if(!$result){
  62. die('There was an error running the query [' . $mysqli->error . ']');
  63. }
  64. }
  65.  
  66. $mysqli->close();
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement