Advertisement
Guest User

Untitled

a guest
Jul 6th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.31 KB | None | 0 0
  1. <?php
  2. //take inputs from register.html
  3. $userNameInput = $_POST['Name'];
  4. $userEmailInput = $_POST['Email'];
  5. $userPasswordInput = $_POST['Password'];
  6. $userWaterInput = $_POST['Water'];
  7. $userImageInput = $_POST['Image'];
  8. $userLocationInput = $_POST['Location'];
  9. $userCourseInput = $_POST['Course'];
  10. $codeID = rand(100, 999);
  11.  
  12. //database connection jazz
  13. $username="webuser";
  14. $password="";
  15. $database="assassin";
  16.  
  17. //connection line
  18. $connected = mysql_connect(localhost,$username,$password);
  19. if (!$connected) {
  20.     die('Could not connect: ' . mysql_error());
  21. }
  22.  
  23. //selects database
  24. mysql_select_db($database, $connected) or die('Unable to select database: ' . $mysql_error());
  25.  
  26. //checks if UID is taken
  27. $checker = 1;
  28. while($checker==1):
  29. $codeidcheck = mysql_select("SELECT name FROM users WHERE codeid = ".$codeID);
  30. if(!$codeidcheck) break;
  31. else $codeID = rand(100, 999);
  32. endwhile;
  33.  
  34. $query = "INSERT INTO users (codeid,name,email,password,water,image,location,course) VALUES ('$codeID','$userNameInput','$userEmailInput','$userPasswordInput','$userWaterInput','$userImageInput','$userLocationInput','$userCourseInput')";
  35. $result = mysql_query($query);
  36.  
  37. if ($result)
  38. {
  39. echo "Data entered!";
  40. echo "Your CodeID (login) is";
  41. print $codeID;
  42. }
  43. else echo "Failed!";
  44.  
  45. //closes database connection
  46. mysql_close();
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement