Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * @author Jason
  5. * @copyright 2010
  6. */
  7.  
  8. include "connect.php";
  9.  
  10. $submit = $_POST['submit'];
  11.  
  12. $username = mysql_real_escape_string( htmlspecialchars( strip_tags( addslashes( $_POST['username'] ) ) ) );
  13. $password = md5( mysql_real_escape_string( htmlspecialchars( strip_tags( addslashes( $_POST['password'] ) ) ) ) );
  14. $repeatpassword = md5( mysql_real_escape_string( htmlspecialchars( strip_tags( addslashes( $_POST['repeatpassword'] ) ) ) ) );
  15. $date = date('Y-m-d');
  16.  
  17. if( isset( $submit ) )
  18. {
  19.  
  20. $query = mysql_query(" SELECT * FROM users WHERE username = '$username' ");
  21. $numrows = mysql_num_rows( $query );
  22.  
  23. if ( $numrows )
  24. {
  25. echo "Username is taken!";
  26. }
  27. else
  28. {
  29.  
  30. if ( $username && $password && $repeatpassword )
  31. {
  32.  
  33. if ( $password == $repeatpassword )
  34. {
  35.  
  36. if ( strlen( $username )>25 )
  37. {
  38. echo "Username must be within 25 characters!";
  39. }
  40.  
  41. if ( strlen( $password )>25 && strlen( $password )<4 )
  42. {
  43. echo "Password must be between 4 to 25 characters!";
  44. }
  45. else
  46. {
  47.  
  48. $register = mysql_query("
  49.  
  50. INSERT INTO users VALUES('','$username','$password','$date')
  51.  
  52. ");
  53.  
  54. echo "You're Registered!";
  55.  
  56. }
  57.  
  58. }
  59. else
  60. {
  61. echo "Your passwords do not match!";
  62. }
  63.  
  64. }
  65. else
  66. {
  67. echo "Please fill in all fields!";
  68. }
  69.  
  70. }
  71.  
  72. }
  73.  
  74. ?>
  75.  
  76. <html>
  77.  
  78. <form action='' method='POST'>
  79.  
  80. Username: <input type="text" name="username"/><br />
  81. Password: <input type="password" name="password"/><br />
  82. Repeat Password: <input type="password" name="repeatpassword"/><br />
  83.  
  84. <input type="submit" name="submit" value="Register"/>
  85.  
  86. </form>
  87.  
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement