Guest User

php-code for form results

a guest
Jan 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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.  
  34. echo '<pre>'.print_r($_POST,1); exit; //comment this line to continue
  35. $name = $_POST['name'];//remember.. name not using capitalize
  36. $email_address = $_POST['email_address'];
  37. $phone = $_POST['phone'];
  38. $comments = $_POST['comments'];
  39. // 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?
  40. //Validate first
  41. if(empty($name)||empty($email_address)) //$visitor_EMAIL_ADDRESS is not valid.. but you should check this should type $EMAIL_ADDRESS
  42. {
  43. echo "Name and email are mandatory!";
  44. //the email will not be empty... but you need to check if the email is valid
  45. // http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
  46. exit;
  47. }
  48.  
  49. $email_from = 'karljames@verizon.net';'gundambison@gmail.com';'kjames1973@gmail.com';//<== Put your email address here
  50. $email_subject = "New Form submission";
  51. $email_body = "You have received a new message from the user $name.\n".
  52. "email address: $visitor_email_address\n".
  53. "Here is the COMMENTS:\n $comments".
  54.  
  55. $to = "karljames@verizon.net";//<== Put your email address here
  56. $headers = "From: $email_from \r\n";
  57.  
  58. //Send the email!
  59. mail($to,$email_subject,$email_body,$headers);
  60. //this email function not always work as we wanted
  61.  
  62. /*
  63. for first.. hope this mail work
  64. if not.. search how to using SMTP or other ways to email...
  65. */
  66. //done. redirect to thank-you page.
  67. header('Location: thank-you.html'); //try not using header...
  68. //using js goto
  69. // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url
  70.  
  71.  
  72.  
  73. ?>
  74. </body>
  75. </html>
Add Comment
Please, Sign In to add comment