Advertisement
Guest User

Untitled

a guest
May 18th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. include("include.php");
  4.  
  5. include("opendb.php");
  6.  
  7. $password = $_POST['password'];
  8.  
  9. $check = "select id from $table where username = '".$_POST['username']."';";
  10. $qry = mysql_query($check) or die ("Could not match data because ".mysql_error());
  11. $num_rows = mysql_num_rows($qry);
  12. if ($num_rows != 0) {
  13. echo "Sorry, the username ".$_POST['username']." is already taken. Please hit the back button and try again.<br>";
  14. exit;
  15. } else {
  16.  
  17. if(
  18. (ctype_alnum($password))// numbers & digits only
  19. && (strlen($password)>6) // at least 7 chars
  20. && (strlen($password)<21) // at most 20 chars
  21. && (preg_match('`[A-Z]`',$password)) // at least one upper case
  22. && (preg_match('`[a-z]`',$password)) // at least one lower case
  23. && (preg_match('`[0-9]`',$password)) // at least one digit
  24. ){
  25.  
  26. $insert = mysql_query("insert into $table values ('NULL', '".$_POST['username']."',
  27. '".$_POST['password']."','".$_POST['firstName']."','".$_POST['lastName']."','".$_POST['emailAddr']."','".$_POST['telephone']."','".$_POST['postCode']."')")
  28. or die("Could not insert data because ".mysql_error());
  29.  
  30.  
  31. echo "Your user account has been created!<br>";
  32. echo "You may now <a href='index.php?tab=2'>log in</a> with your username and password.";
  33.  
  34. }else{
  35. echo "Password does not meet requirements. Blah blah.";
  36. }
  37.  
  38. }
  39.  
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement