Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <html>
  2. <body>
  3. <?php
  4. if ($_POST)
  5. {
  6. require_once 'db.php';
  7.  
  8. $username = mysql_real_escape_string(preg_replace('/[a-zA-Z0-9]/', '', $_POST['username'])); // Only allows alphanumeric characters for username
  9. $password = $_POST['password'];
  10. $confirm = $_POST['confirm'];
  11. if ($_POST['username'] !== $username) // Check username input
  12. {
  13.  
  14. echo 'Your username must only contains alphanumeric characters';
  15.  
  16. }
  17. elseif ($password !== $confirm) // Check password confirmation
  18. {
  19.  
  20. echo 'Your password do not match';
  21.  
  22. }
  23. else
  24. {
  25.  
  26. $result = mysql_query('SELECT COUNT(id) AS found FROM users WHERE username = "'.$username.'"');
  27. if($result) // Username taken
  28. {
  29.  
  30. echo 'Username is already taken';
  31.  
  32. }
  33. else
  34. {
  35.  
  36. $password .= '46jhdgj$^&#$^+_DF';
  37. $password = mysql_real_escape_string(sha1(strrev($password)));
  38. mysql_query('INSERT INTO users (id, username, password) VALUES ("", "'.$username.'", "'.$password.'")'); // Insert the registration data to the database... (id, username, password)
  39.  
  40. echo 'Successfully registered!';
  41.  
  42. }
  43. }
  44.  
  45. }
  46. ?>
  47. <form name='register' method='post' action='register.php'>
  48. Username: <input type='text' name='username' /><br />
  49. Password: <input type='text' name='password' /><br />
  50. Confirm: <input type='text' name='confirm' /><br />
  51. <input type='submit' value='Submit' />
  52. </form>
  53.  
  54. </body>
  55. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement