Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <?php
  2. /* Check all form inputs using check_input function */
  3. $username = check_input($_POST['username'], "tptunlimited");
  4. $password = check_input($_POST['password'], "B@seball96");
  5. $comments = check_input($_POST['comments'], "comment");
  6. /* If username is not valid show error message */
  7. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $username))
  8. {
  9. show_error("username not valid");
  10. }
  11. /* If password is not valid set $website to empty */
  12. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $password))
  13. {
  14. show_error("password not valid");
  15. }
  16. /* Redirect visitor to the thank you page */
  17. header('Location: thanks.htm');
  18. exit();
  19. /* Functions we used */
  20. function check_input($data, $problem='')
  21. {
  22. $data = trim($data);
  23. $data = stripslashes($data);
  24. $data = htmlspecialchars($data);
  25. if ($problem && strlen($data) == 0)
  26. {
  27. show_error($problem);
  28. }
  29. return $data;
  30. }
  31. function show_error($myError)
  32. {
  33. ?>
  34. <html>
  35. <body>
  36. <b>Please correct the following error:</b><br />
  37. <?php echo $myError; ?>
  38. </body>
  39. </html>
  40. <?php
  41. exit();
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement