Guest User

Untitled

a guest
Aug 25th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', '1');
  5.  
  6. include("config.php");
  7. function validateEmail($email){
  8.  
  9. $pattern = '/^w[wd]+(.[wd]+)*@w[wd]+(.[wd]+)*.[a-z]{2,7}$/i';
  10.  
  11. return preg_match($pattern,$email);
  12.  
  13. }
  14.  
  15.  
  16.  
  17. if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']) && isset($_POST['secQ']) && isset($_POST['secA'])) {
  18.  
  19.  
  20. // email validation function
  21.  
  22.  
  23. $username = mysql_real_escape_string($_POST['username']);
  24. $email = mysql_real_escape_string($_POST['email']);
  25. $secQ = mysql_real_escape_string($_POST['secQ']);
  26. $secA = mysql_real_escape_string($_POST['secA']);
  27. $password = $_POST['password'];
  28. if(!validateEmail($email))
  29. {
  30. die("email not correct");
  31. }else
  32. {
  33.  
  34. mysql_query("INSERT INTO admin (username, password, email, secquestion, secanswer, sendemail) VALUES ( '$username', '$password', '$email', '$secQ', '$secA','1')") or die (mysql_error()); echo "Account created.";
  35. echo "User registerd ";
  36. die("");
  37. }
  38. }
  39.  
  40. ?>
  41.  
  42.  
  43.  
  44. <html></html>
  45.  
  46. <form action="register.php" method="post">
  47. <br>
  48. <br>
  49. Username: <input name="username" type="text" />
  50. <br>
  51. <br>
  52. Password: <input type="password" name="password" />
  53. <br>
  54. <br>
  55. Email: <input name="email" type="text" />
  56. <br>
  57. <br>
  58. Choose a secret question.
  59. <select name="secQ">
  60. <option disabled selected value="0">Choose Option</option>
  61. <option value="1">What is your middle name?</option>
  62. <option value="2">What is your mothers maiden name?</option>
  63. <option value="3">What city were you born in?</option>
  64. <option value="4">What is your favorite color?</option>
  65. <option value="5">What year did you graduate from High School?</option>
  66. <option value="6">What was the name of your first boyfriend/girlfriend?</option>
  67. <option value="7">What is your favorite model of car?</option>
  68. </select>
  69. <br>
  70. <br>
  71. Pick a secret answer: <input name="secA" type="text" />
  72.  
  73. </select>
  74. <br>
  75. <br>
  76. <input type="submit" value="Submit" />
  77.  
  78. </form>
Add Comment
Please, Sign In to add comment