contactengine.php 905 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. $EmailFrom = "admin@webmaster.com";
  3. $EmailTo = "your@email.com";
  4. $Subject = "Message from Backyard visitor";
  5. $Name = Trim( stripslashes( $_POST[ 'Name' ] ) );
  6. $Email = Trim( stripslashes( $_POST[ 'Email' ] ) );
  7. $Message = Trim( stripslashes( $_POST[ 'Message' ] ) );
  8. // validation
  9. $validationOK = true;
  10. if ( !$validationOK ) {
  11. print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  12. exit;
  13. }
  14. // prepare email body text
  15. $Body = "";
  16. $Body .= "Name: ";
  17. $Body .= $Name;
  18. $Body .= "\n";
  19. $Body .= "Email: ";
  20. $Body .= $Email;
  21. $Body .= "\n";
  22. $Body .= "Message: ";
  23. $Body .= $Message;
  24. $Body .= "\n";
  25. // send email
  26. $success = mail( $EmailTo, $Subject, $Body, "From: <$EmailFrom>" );
  27. // redirect to success page
  28. if ( $success ) {
  29. print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
  30. } else {
  31. print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  32. }