Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Define some constants
- define( "RECIPIENT_NAME", "John Smith" );
- define( "RECIPIENT_EMAIL", "john@example.com" );
- define( "EMAIL_SUBJECT", "Visitor Message" );
- // Read the form values
- $success = false;
- $senderName = isset( $_POST['senderName'] ) ? preg_replace( "/[^.-' a-zA-Z0-9]/", "", $_POST['senderName'] ) : "";
- $senderEmail = isset( $_POST['senderEmail'] ) ? preg_replace( "/[^.-_@a-zA-Z0-9]/", "", $_POST['senderEmail'] ) : "";
- $message = isset( $_POST['message'] ) ? preg_replace( "/(From:|To:|BCC:|CC:|Subject:|Content-Type:)/", "", $_POST['message'] ) : "";
- // If all values exist, send the email
- if ( $senderName && $senderEmail && $message ) {
- $recipient = RECIPIENT_NAME . " <" . RECIPIENT_EMAIL . ">";
- $headers = "From: " . $senderName . " <" . $senderEmail . ">";
- $success = mail( $recipient, EMAIL_SUBJECT, $message, $headers );
- }
- // Return an appropriate response to the browser
- if ( isset($_GET["ajax"]) ) {
- echo $success ? "success" : "error";
- } else {
- ?>
- <html>
- <head>
- <title>Thanks!</title>
- </head>
- <body>
- <?php if ( $success ) echo "<p>Thanks for sending your message! We'll get back to you shortly.</p>" ?>
- <?php if ( !$success ) echo "<p>There was a problem sending your message. Please try again.</p>" ?>
- <p>Click your browser's Back button to return to the page.</p>
- </body>
- </html>
- <?php
- }
- ?>
- if ($success) {
- header("Location: /success.html");
- exit;
- } else {
- header("Location: /error.html");
- exit;
- }
- if ($success == 'success') {
- header("Location: success.html");
- exit;
- } else {
- header("Location: error.html");
- exit;
- }
- if($success) {
- header('location:contact_success.html');
- }
- else {
- header('location:contact_error.html');
- }
- <?php
- $goto_after_mail = "http://www.domain.com"; // This is the URL that is shown after the mail is submitted.
- $from_mail = $_REQUEST['email']; // Be sure your EMAIL form field is identified as "email".
- $from_name = $_REQUEST['name']; // Be sure your NAME form field is identified as "name".
- $header = "From: \"$from_name\" <$from_mail>\r
- ";
- $header .= "MIME-Version: 1.0\r
- ";
- $header .= "Content-Type: text/plain; charset=\"utf-8\"\r
- ";
- $header .= "Content-Transfer-Encoding: 7bit\r
- ";
- $subject = "Your Message Subject"; // Insert your message subject.
- foreach ($_REQUEST as $key => $val) {
- if ($key != "" && $key != "") {
- $body .= $key . " : " . $val . "\r
- ";
- }
- }
- if (mail("mail@domain.com", $subject, $body, $header)) { // Insert your e-mail address to be used to view your submissions.
- header("Location: ".$goto_after_mail);
- }
- ?>
- //Email Notification
- // the message
- $msg = $today." : A NEW Message.nProperty: ".$property."Value: ".$Value."n";
- // use wordwrap() if lines are longer than 70 characters
- // we'll use base 64 if needed with the later email templates
- $msg = wordwrap($msg,70);
- // old send email
- //mail("lifelinkdistribution@gmail.com,info@directordigitalmedia.com","some Message",$msg);
- // Redirect after the mail is sent so they are not blank
- if (mail("someemail@address.com"," - A New LifeLink Lead Has Been Posted",$msg)){
- // To redirect form on a particular page
- header("Location: http://google.com");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement