Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. <?php
  2. if(!isset($_POST['submit']))
  3. {
  4. //This page should not be accessed directly. Need to submit the form.
  5. //echo "error; you need to submit the form!";
  6. header("location:index.html");//you can change later
  7. }
  8.  
  9. echo '<pre>'.print_r($_POST,1); exit; //comment this line to continue
  10. $name = $_POST['name'];//remember.. name not using capitalize
  11. $email_address = $_POST['email_address'];
  12. $phone = $_POST['phone'];
  13. $comments = $_POST['comments'];
  14. // better using read able name.. above is fine.. but using capitalize name whould be hard to type, I understand that so I should LC all of it. but also make suret the values match the form names right?
  15. //Validate first
  16. if(empty($name)||empty($email_address)) //$visitor_EMAIL_ADDRESS is not valid.. but you should check this should type $EMAIL_ADDRESS
  17. {
  18. echo "Name and email are mandatory!";
  19. //the email will not be empty... but you need to check if the email is valid
  20. // http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
  21. exit;
  22. }
  23.  
  24. $email_from = 'karljames@verizon.net';'gundambison@gmail.com';'kjames1973@gmail.com';//<== Put your email address here
  25. $email_subject = "New Form submission";
  26. $email_body = "You have received a new message from the user $name.\n".
  27. "email address: $visitor_email_address\n".
  28. "Here is the COMMENTS:\n $comments".
  29.  
  30. $to = "karljames@verizon.net";//<== Put your email address here
  31. $headers = "From: $email_from \r\n";
  32.  
  33. //Send the email!
  34. mail($to,$email_subject,$email_body,$headers);
  35. //this email function not always work as we wanted
  36.  
  37. /*
  38. for first.. hope this mail work
  39. if not.. search how to using SMTP or other ways to email...
  40. */
  41. //done. redirect to thank-you page.
  42. header('Location: thank-you.html'); //try not using header...
  43. //using js goto
  44. // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url
  45.  
  46.  
  47.  
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement