Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- //check input fields for error
- $errors = '';
- $myemail = 'myemail@example.com';//<-----Put Your email address here.
- if(empty($_POST['name']) ||
- empty($_POST['phone']) ||
- empty($_POST['email']))
- {
- $errors .= "\n Error: all fields are required";
- }
- //call from form1.php
- $address = $_SESSION['address'];
- //call from form2.php
- $condition_home = $_SESSION['condition_home'];
- $selling_plan = $_SESSION['selling_plan'];
- $comment = $_SESSION['comment'];
- $name = $_POST['name'];
- $phone = $_POST['phone'];
- $email_address = $_POST['email'];
- //redirect to second page
- if( empty($errors))
- {
- $to = $myemail;
- $email_subject = "Contact form submission: $name";
- $email_body = "You have received a new message. ".
- " Here are the details:\n Name: $name \n Email: $email_address \n Phone Number: $phone \n\n Address: $address \n Home Condition: $home_condition \n Selling Plan: $selling_plan \n Comment: $comment";
- $headers = "From: $email_address\n";
- $headers .= "Reply-To: $email_address";
- mail($to,$email_subject,$email_body,$headers);
- //redirect to the "Thank You" page
- header('Location: thankyou_page.php');
- }
- ?>
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <title>Contact form handler</title>
- </head>
- <body>
- <!-- This page is displayed only if there is some error -->
- <?php
- echo nl2br($errors);
- ?>
- <br />
- <a href="landing_page.php">Return to Home</a>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement