Guest User

the form PHP

a guest
Nov 25th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2. if (isset($_POST["submit"])) {
  3.  
  4. $name = Input::get('name');
  5. $email = $_POST['email'];
  6. $message = $_POST['message'];
  7. $human = intval($_POST['human']);
  8. $from = $user->data()->email;
  9. $to = $thatUser->email;
  10. $subject = 'Message from Local Positivity Finder';
  11.  
  12. $body ="From: $name\n E-Mail: $email\n Message: $message\n";
  13.  
  14. // Check if name has been entered
  15. if (!$_POST['name']) {
  16. $errName = 'Please enter your name';
  17. }
  18.  
  19. // Check if email has been entered and is valid
  20. if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
  21. $errEmail = 'Please enter a valid email address';
  22. }
  23.  
  24. //Check if message has been entered
  25. if (!$_POST['message']) {
  26. $errMessage = 'Please enter your message';
  27. }
  28. //Check if simple anti-bot test is correct
  29. if ($human !== 5) {
  30. $errHuman = 'Your anti-spam is incorrect';
  31. }
  32.  
  33. // If there are no errors, send the email
  34. if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
  35. if (mail ($to, $subject, $body)) {
  36. Redirect::to($us_url_root.'users/contact_success.php');
  37. } else {
  38. Redirect::to($us_url_root.'users/contact_error.php');
  39. }
  40. }
  41. }
  42.  
  43. ?>
Add Comment
Please, Sign In to add comment