Advertisement
Guest User

For G

a guest
Jan 22nd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Contact Form Results - Being Emailed To GlotekMedia.com</title>
  6. </head>
  7.  
  8. <body>
  9. <javascirpt>
  10. function validateForm()
  11. {
  12. var name=document.forms["feedbackForm"]["name"].value;
  13. if (name==null || name=="")
  14. {
  15. alert("Name cannot be left blank");
  16. return false;
  17. }
  18.  
  19. var z=document.forms["feedbackForm"]["message"].value;
  20. if (z==null || z=="")
  21. {
  22. alert("Please Enter a Message");
  23. return false;
  24. }
  25. </javascirpt>
  26. <?php
  27. if(!isset($_POST['submit']))
  28. {
  29. //This page should not be accessed directly. Need to submit the form.
  30. //echo "error; you need to submit the form!";
  31. header("location:index.html");//you can change later
  32. }
  33. $name = $_POST['name'];//remember.. name not using capitalize
  34. $email_address = $_POST['email_address'];
  35. $phone = $_POST['phone'];
  36. $comments = $_POST['comments'];
  37. // 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?
  38. //Validate first
  39. if(empty($name)||empty($visitor_email_address)) //$visitor_EMAIL_ADDRESS is not valid.. but you should check this should type $EMAIL_ADDRESS
  40. {
  41. echo "Name and email are mandatory!";
  42. //the email will not be empty... but you need to check if the email is valid
  43. // http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
  44. exit;
  45. }
  46.  
  47. $email_from = 'karljames@verizon.net';//<== Put your email address here
  48. $email_subject = "New Form submission";
  49. $email_body = "You have received a new message from the user $name.\n".
  50. "email address: $visitor_email_address\n".
  51. "Here is the COMMENTS:\n $comments".
  52.  
  53. $to = "karljames@verizon.net";//<== Put your email address here
  54. $headers = "From: $email_from \r\n";
  55.  
  56. //Send the email!
  57. mail($to,$email_subject,$email_body,$headers); //this email function not always work as we wanted
  58. /*
  59. for first.. hope this mail work
  60. if not.. search how to using SMTP or other ways to email...
  61. */
  62. //done. redirect to thank-you page.
  63. header('Location: thank-you.html'); //try not using header...
  64. //using js goto
  65. // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url
  66.  
  67.  
  68. ?>
  69. </body>
  70. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement