Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Contact Form Results - Being Emailed To GlotekMedia.com</title>
- </head>
- <body>
- <javascirpt>
- function validateForm()
- {
- var name=document.forms["feedbackForm"]["name"].value;
- if (name==null || name=="")
- {
- alert("Name cannot be left blank");
- return false;
- }
- var z=document.forms["feedbackForm"]["message"].value;
- if (z==null || z=="")
- {
- alert("Please Enter a Message");
- return false;
- }
- </javascirpt>
- <?php
- if(!isset($_POST['submit'])){
- //This page should not be accessed directly. Need to submit the form.
- echo "error; you need to submit the form!";exit; //you can comment this
- header("location:index.html");//you can change later
- }
- 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
- $name = $_POST['name'];//remember.. name not using capitalize
- $email_address = $_POST['email_address'];
- $phone = $_POST['phone'];
- $comments = $_POST['comments'];
- // 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?
- //Validate first
- if(empty($name)||empty($email_address)) //$visitor_EMAIL_ADDRESS is not valid.. but you should check this should type $EMAIL_ADDRESS
- {
- echo "Name and email are mandatory!";
- //the email will not be empty... but you need to check if the email is valid
- // http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php
- exit;
- }
- $email_from = 'karljames@verizon.net';'gundambison@gmail.com';'kjames1973@gmail.com';//<== Put your email address here
- $email_subject = "New Form submission";
- $email_body = "You have received a new message from the user $name.\n".
- "email address: $visitor_email_address\n".
- "Here is the COMMENTS:\n $comments".
- $to = "karljames@verizon.net";//<== Put your email address here
- $headers = "From: $email_from \r\n";
- //Send the email!
- mail($to,$email_subject,$email_body,$headers);
- //this email function not always work as we wanted
- /*
- for first.. hope this mail work
- if not.. search how to using SMTP or other ways to email...
- */
- //done. redirect to thank-you page.
- die('the email send? if not.. try to read the code again.. if yes.. comment this line');
- header('Location: thank-you.html'); //try not using header...
- //using js goto
- // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement