Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 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.  
  16. if( isset( $submit ) )
  17. {
  18.  
  19. $query = mysql_query(" SELECT * FROM users WHERE username = '$username' ");
  20. $numrows = mysql_num_rows( $query );
  21.  
  22. if ( $numrows )
  23. {
  24. echo "Username is taken!";
  25. }
  26.  
  27. if ( $username && $password && $repeatpassword )
  28. {
  29.  
  30. if ( strlen( $username )>25 )
  31. {
  32. echo "Username must be within 25 characters!";
  33. }
  34.  
  35. if ( strlen( $password )>25 && strlen( $password )<4 )
  36. {
  37. echo "Password must be between 4 to 25 characters!";
  38. }
  39.  
  40. }
  41. else
  42. {
  43. echo "Please fill in all fields!";
  44. }
  45.  
  46. }
  47.  
  48. ?>
  49.  
  50. <html>
  51.  
  52. <form action='' method='POST'>
  53.  
  54. Username: <input type="text" name="username"/><br />
  55. Password: <input type="password" name="password"/><br />
  56. Repeat Password: <input type="password" name="repeatpassword"/><br />
  57.  
  58. <input type="submit" name="submit" value="Register"/>
  59.  
  60. </form>
  61.  
  62. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement