Advertisement
GWibisono

read the comment

Jan 24th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     //This page should not be accessed directly. Need to submit the form.
  29.     echo "error; you need to submit the form!";exit; //you can comment this
  30.     header("location:index.html");//you can change later
  31. }
  32.  
  33. echo 'your are seing this... if you see this.. you forgot to comment the line.. no email has send if you see this <pre>'.print_r($_POST,1); exit; //comment this line to continue
  34. $name = $_POST['name'];//remember.. name not using capitalize
  35. $email_address = $_POST['email_address'];
  36. $phone = $_POST['phone'];
  37. $comments = $_POST['comments'];
  38.  // 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?
  39. //Validate first
  40. if(empty($name)||empty($email_address))  //$visitor_EMAIL_ADDRESS is not valid.. but you should  check this should type $EMAIL_ADDRESS
  41. {
  42.     echo "Name and email are mandatory!";
  43.     //the email will not be empty... but you need to check if the email is valid
  44.     //   http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
  45.     exit;
  46. }
  47.  
  48. $email_from = 'karljames@verizon.net';'gundambison@gmail.com';'kjames1973@gmail.com';//<== Put your email address here
  49. $email_subject = "New Form submission";
  50. $email_body = "You have received a new message from the user $name.\n".
  51.     "email address: $visitor_email_address\n".
  52.     "Here is the COMMENTS:\n $comments".
  53.      
  54. $to = "karljames@verizon.net";//<== Put your email address here
  55. $headers = "From: $email_from \r\n";
  56.  
  57. //Send the email!
  58. mail($to,$email_subject,$email_body,$headers);
  59. //this email function not always work as we wanted
  60.  
  61.     /*
  62.     for first.. hope this mail work
  63.     if not.. search how to using SMTP or other ways to email...
  64.     */
  65. //done. redirect to thank-you page.
  66. die('the email send? if not.. try to read the code again.. if yes.. comment this line');
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement