Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. <?php
  2.  
  3. // Define some constants
  4. define( "RECIPIENT_NAME", "John Smith" );
  5. define( "RECIPIENT_EMAIL", "john@example.com" );
  6. define( "EMAIL_SUBJECT", "Visitor Message" );
  7.  
  8. // Read the form values
  9. $success = false;
  10. $senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^.-' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
  11. $senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^.-_@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
  12. $message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
  13.  
  14. // If all values exist, send the email
  15. if ( $senderName && $senderEmail && $message ) {
  16. $recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
  17. $headers = "From: " . $senderName . " <" . $senderEmail . ">";
  18. $success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
  19. }
  20.  
  21. // Return an appropriate response to the browser
  22. if ( isset($_GET["ajax"]) ) {
  23. echo $success ? "success" : "error";
  24. } else {
  25. ?>
  26. <html>
  27. <head>
  28. <title>Thanks!</title>
  29. </head>
  30. <body>
  31. <?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
  32. <?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
  33. <p>Click your browser's Back button to return to the page.</p>
  34. </body>
  35. </html>
  36. <?php
  37. }
  38. ?>
  39.  
  40. if ($success) {
  41. header("Location: /success.html");
  42. exit;
  43. } else {
  44. header("Location: /error.html");
  45. exit;
  46. }
  47.  
  48. if ($success == 'success') {
  49. header("Location: success.html");
  50. exit;
  51. } else {
  52. header("Location: error.html");
  53. exit;
  54. }
  55.  
  56. if($success) {
  57. header('location:contact_success.html');
  58. }
  59. else {
  60. header('location:contact_error.html');
  61. }
  62.  
  63. <?php
  64. $goto_after_mail = "http://www.domain.com"; // This is the URL that is shown after the mail is submitted.
  65. $from_mail = $_REQUEST['email']; // Be sure your EMAIL form field is identified as "email".
  66. $from_name = $_REQUEST['name']; // Be sure your NAME form field is identified as "name".
  67. $header = "From: \"$from_name\" <$from_mail>\r
  68. ";
  69. $header .= "MIME-Version: 1.0\r
  70. ";
  71. $header .= "Content-Type: text/plain; charset=\"utf-8\"\r
  72. ";
  73. $header .= "Content-Transfer-Encoding: 7bit\r
  74. ";
  75. $subject = "Your Message Subject"; // Insert your message subject.
  76. foreach ($_REQUEST as $key => $val) {
  77. if ($key != "" && $key != "") {
  78. $body .= $key . " : " . $val . "\r
  79. ";
  80. }
  81. }
  82. if (mail("mail@domain.com", $subject, $body, $header)) { // Insert your e-mail address to be used to view your submissions.
  83. header("Location: ".$goto_after_mail);
  84. }
  85. ?>
  86.  
  87. //Email Notification
  88. // the message
  89. $msg = $today." : A NEW Message.nProperty: ".$property."Value: ".$Value."n";
  90.  
  91. // use wordwrap() if lines are longer than 70 characters
  92. // we'll use base 64 if needed with the later email templates
  93. $msg = wordwrap($msg,70);
  94.  
  95. // old send email
  96. //mail("lifelinkdistribution@gmail.com,info@directordigitalmedia.com","some Message",$msg);
  97.  
  98. // Redirect after the mail is sent so they are not blank
  99. if (mail("someemail@address.com"," - A New LifeLink Lead Has Been Posted",$msg)){
  100. // To redirect form on a particular page
  101. header("Location: http://google.com");
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement