Guest User

Untitled

a guest
Aug 21st, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <?php
  2. $user_name = '';
  3. $user_email = '';
  4. $username = '';
  5. $password = '';
  6. $verify = '';
  7. $email = '';
  8. $have_error = false;
  9. include "validation_function.php";
  10. if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['verify'])){
  11. $user_name = $_POST['username'];
  12. $user_email = $_POST['email'];
  13. if(!valid_user_name($_POST['username'])){
  14. $username = "That's not a valid username.";
  15. $have_error = true;
  16. }
  17. if(!valid_password($_POST['password'])){
  18. $password = "That wasn't a valid password.";
  19. $have_error = true;
  20. }
  21. else if($_POST['password'] !== $_POST['verify']){
  22. $verify = "Your passwords didn't match.";
  23. $have_error = true;
  24. }
  25. if(!valid_email($_POST['email'])){
  26. $email = "That's not a valid email";
  27. $have_error = true;
  28. }
  29. if(!$have_error){
  30. header('Location: thanks.php?username='.$_POST['username']);
  31. return;
  32. }
  33. }
  34. ?>
  35. <!DOCTYPE html>
  36. <html>
  37. <head>
  38. <title>Sign Up</title>
  39. <style type="text/css">
  40. .label {text-align: right}
  41. .error {color: red}
  42. </style>
  43. </head>
  44. <body>
  45. <h2>Signup</h2>
  46. <form method="post">
  47. <table>
  48. <tr>
  49. <td class="label">
  50. Username
  51. </td>
  52. <td>
  53. <input type="text" name="username" value="<?= htmlentities($user_name)?>">
  54. </td>
  55. <td class="error">
  56. <?= $username ?>
  57. </td>
  58. </tr>
  59. <tr>
  60. <td class="label">
  61. Password
  62. </td>
  63. <td>
  64. <input type="password" name="password" value="">
  65. </td>
  66. <td class="error">
  67. <?= $password ?>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="label">
  72. Verify Password
  73. </td>
  74. <td>
  75. <input type="password" name="verify" value="">
  76. </td>
  77. <td class="error">
  78. <?= $verify ?>
  79. </td>
  80. </tr>
  81. <tr>
  82. <td class="label">
  83. Email (optional)
  84. </td>
  85. <td>
  86. <input type="text" name="email" value="<?= htmlentities($user_email)?>">
  87. </td>
  88. <td class="error">
  89. <?= $email ?>
  90. </td>
  91. </tr>
  92. </table>
  93. <input type="submit">
  94. </form>
  95. </body>
  96. </html>
Add Comment
Please, Sign In to add comment