Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['submit'])) {
  4.  
  5. mysql_connect("localhost", "root", "") or die(mysql_error());
  6. mysql_select_db("noveen") or die(mysql_error());
  7.  
  8. $username = $_POST['username'];
  9. $password = $_POST['password'];
  10.  
  11. if(empty($password) || empty($username)) {
  12. echo "You need to fill out the form first.";
  13. exit();
  14. }
  15.  
  16. $md5 = md5($password);
  17.  
  18. $check = mysql_query("SELECT `username` FROM `users` WHERE `username` = $username") or die(mysql_error());
  19. $num = mysql_num_rows($check);
  20. if($num === 1) {
  21. echo "Your username is already in use.";
  22. exit();
  23. }
  24.  
  25. else {
  26.  
  27. $usernametwo = stripslashes($username);
  28. mysql_query("INSERT INTO `users` (username, password) VALUES ($usernametwo, $md5)") or die(mysql_error());
  29.  
  30. }
  31.  
  32. echo "You have successfully registered.";
  33. }
  34.  
  35. else {
  36.  
  37. echo "Please fill out the form below.";
  38.  
  39. }
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement