Advertisement
Guest User

Untitled

a guest
Aug 6th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2.  
  3. /* These are the variable that tell the subject of the email and where the email will be sent.*/
  4.  
  5. $emailSubject = 'Customer Has a Question!';
  6. $mailto = 'meya@digihaul.com';
  7.  
  8. /* These will gather what the user has typed into the fieled. */
  9.  
  10. $nameField = $_POST['name'];
  11. $addressField = $_POST['address'];
  12. $cityField = $_POST['city'];
  13. $stateField = $_POST['state'];
  14. $zipField = $_POST['zip'];
  15. $phoneField = $_POST['phone'];
  16. $emailField = $_POST['email'];
  17. $contactField = $_POST['contact'];
  18. $serviceField = $_POST['service'];
  19. $questionField = $_POST['info'];
  20.  
  21. /* This takes the information and lines it up the way you want it to be sent in the email. */
  22.  
  23. $body = <<<EOD
  24. <br><hr><br>
  25. Name: $nameField <br>
  26. Phone: $phoneField <br>
  27. Email: $emailField <br>
  28. Adress: $addressField <br>
  29. City, State Zip: $cityField, $stateField $zipField <br>
  30. Contact Preference: $contactField <br>
  31. Service: $serviceField <br>
  32. Info: $questionField <br>
  33. EOD;
  34.  
  35. echo $body;
  36.  
  37. $headers = "From: $emailFieldrn"; // This takes the email and displays it as who this email is from.
  38. $headers .= "Content-type: text/htmlrn"; // This tells the server to turn the coding into the text.
  39.  
  40.  
  41. if (!preg_match("/w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*/", $emailField)) {
  42. echo "<h4>Invalid email address</h4>";
  43. echo "<a href='javascript:history.back(1);'>Back</a>";
  44. } elseif ($nameField == "") {
  45. echo "<h4>No Name</h4>";
  46. echo "<a href='javascript:history.back(1);'>Back</a>";
  47. }
  48.  
  49. /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
  50. elseif (mail($mailto, $emailSubject, $body, $headers)) {
  51. echo "<h4>Thank you for sending email</h4>";
  52. }
  53. else {
  54. echo "<h4>Can't send email to $emailField</h4>";
  55. }
  56. ?>
  57.  
  58. Name: Able Care
  59. Phone: 4175555555
  60. Email: meya@email.com
  61. Adress: 1205 S Fake Ave
  62. City, State Zip: Springfield, MO 65807
  63. Contact Preference: email
  64. Service: shrub
  65. Info: Data Entered
  66.  
  67. Can't send email to meya@email.com
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement