daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Jan 20th, 2017 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if(preg_match("/S+/", $_POST['username']) === 0){
  2.     echo $errors['username'] = "* First Name is required.";
  3. }
  4.  
  5. if(preg_match("/.+@.+..+/", $_POST['email']) === 0){
  6.     echo $errors['email'] = "* Not a valid e-mail address.";
  7. }
  8.  
  9. if(strcmp($_POST['password'], $_POST['confirm_password'])){
  10.     echo $errors['confirm_password'] = "* Password do not much.";
  11. }
  12.    
  13. $usercheckquery = "SELECT * FROM users WHERE username = '$_POST[username]'";
  14. $usercheckresult = mysql_query($usercheckquery);
  15. $data = mysql_fetch_array($usercheckresult);
  16.     if($data[0] > 1) {
  17.         echo "username Already in Exists</br>"; }
  18. $emailcheckquery = "SELECT * FROM users WHERE email = '$_POST[email]'";
  19. $emailcheckresult = mysql_query($emailcheckquery);
  20.     $data = mysql_fetch_array($emailcheckresult);
  21.         if($data[0] > 1) {
  22.                 echo "email Already in Exists</br>"; }
  23.    
  24. <form method="post" action="">
  25. <p>username :
  26. <input type="text" name="username"></p>
  27.  
  28. <p>password :
  29. <input type="password" name="password"></p>
  30.  
  31. <p>re-type password :
  32. <input type="password" name="confirm_password"></p>
  33.  
  34. <p>email :
  35. <input type="text" name="email"></p>
  36.  
  37. <input type="submit" name="register" value="submit">
  38. <a href="index.php">log in</a>
  39.  
  40. </form>
  41.    
  42. $errors = array();
  43.  
  44. if($_SERVER['REQUEST_METHOD'] == 'POST'){
  45. //a1
  46. if(preg_match("/S+/", $_POST['username']) === 0){
  47.     echo $errors['username'] = "* First Name is required.</br>";
  48. }
  49.  
  50. if(preg_match("/.+@.+..+/", $_POST['email']) === 0){
  51.     echo $errors['email'] = "* Not a valid e-mail address.</br>";
  52. }
  53.  
  54. if(strcmp($_POST['password'], $_POST['confirm_password'])){
  55.     echo $errors['confirm_password'] = "* Password do not much.</br>";
  56. }
  57.  
  58.      if (isset($_POST['register'])) {
  59.  
  60. $username = mysql_real_escape_string($_POST['username']);
  61. $password = mysql_real_escape_string($_POST['password']);
  62. $email = mysql_real_escape_string($_POST['email']);
  63.  
  64. //a2
  65. $usercheckquery = "SELECT * FROM users WHERE username = '$_POST[username]'";
  66. $usercheckresult = mysql_query($usercheckquery);
  67. $data = mysql_fetch_array($usercheckresult);
  68.     if($data[0] > 1) {
  69.         echo "username Already in Exists</br>"; }
  70. $emailcheckquery = "SELECT * FROM users WHERE email = '$_POST[email]'";
  71. $emailcheckresult = mysql_query($emailcheckquery);
  72.     $data = mysql_fetch_array($emailcheckresult);
  73.         if($data[0] > 1) {
  74.                 echo "email Already in Exists</br>"; }
  75. else {
  76.       $query = "INSERT INTO `users` (username, password, email) VALUES     ('$username', '$password', '$email')";
  77.       $result = mysql_query($query);
  78.       if($result){
  79.         echo "User Created Successfully.";
  80.         }
  81.     }
  82. }    
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top