Advertisement
Guest User

Untitled

a guest
Jun 17th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. include("db.php");
  3. if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']))
  4.  
  5. {
  6. //Prevent SQL injections
  7. $username = mysql_real_escape_string($_POST['username']);
  8. $email = mysql_real_escape_string($_POST['email']);
  9.  
  10.  
  11. //Get MD5 hash of password
  12. $password = md5($_POST['password']);
  13.  
  14. //Check to see if username exists
  15. $sql = mysql_query("SELECT `username` FROM `users` WHERE `username` = '".$username."'");
  16. if(mysql_num_rows($sql) > 0)
  17. {
  18. die ("Username taken.");
  19. }
  20.  
  21.  
  22. mysql_query("INSERT INTO users (username, pass, email) VALUES ( '$username', '$password', '$email')") or die (mysql_error()); echo "Account created.";
  23.  
  24. }
  25. ?>
  26. <form action="register.php" method="post">
  27. Username: <input name="username" type="text" /><br>
  28. Password: <input type="password" name="password" /><br>
  29. Email: <input name="email" type="text" /><br>
  30. <input type="submit" value="Submit" />
  31. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement