Advertisement
GWibisono

hope this help

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