Advertisement
Guest User

Form 3

a guest
Apr 4th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. //check input fields for error
  5. $errors = '';
  6. $myemail = 'myemail@example.com';//<-----Put Your email address here.
  7.  
  8. if(empty($_POST['name'])  ||
  9.    empty($_POST['phone']) ||
  10.    empty($_POST['email']))
  11. {
  12.     $errors .= "\n Error: all fields are required";
  13. }
  14. //call from form1.php
  15. $address = $_SESSION['address'];
  16.  
  17. //call from form2.php
  18. $condition_home = $_SESSION['condition_home'];
  19. $selling_plan = $_SESSION['selling_plan'];
  20. $comment = $_SESSION['comment'];
  21.  
  22. $name = $_POST['name'];
  23. $phone = $_POST['phone'];
  24. $email_address = $_POST['email'];
  25.  
  26. //redirect to second page
  27. if( empty($errors))
  28. {
  29.     $to = $myemail;
  30.     $email_subject = "Contact form submission: $name";
  31.     $email_body = "You have received a new message. ".
  32.     " 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";
  33.    
  34.     $headers = "From: $email_address\n";
  35.     $headers .= "Reply-To: $email_address";
  36.    
  37.     mail($to,$email_subject,$email_body,$headers);
  38.     //redirect to the "Thank You" page
  39.     header('Location: thankyou_page.php');
  40. }
  41.  
  42. ?>
  43.  
  44. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  45. <html>
  46. <head>
  47.         <title>Contact form handler</title>
  48. </head>
  49.  
  50. <body>
  51. <!-- This page is displayed only if there is some error -->
  52. <?php
  53. echo nl2br($errors);
  54. ?>
  55. <br />
  56. <a href="landing_page.php">Return to Home</a>
  57.  
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement