Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_POST['name']))
- {
- //This page should not be accessed directly. Need to submit the form.
- echo "error; you need to submit the form!";
- die();//header("location:index.html");//you can change later
- }
- //echo '<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';//'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: {$email_address}\n".
- "Here is the COMMENTS:\n $comments";
- $to = "karljames@verizon.net"; //"karljames@verizon.net";//<== Put your email address here
- //$headers = "From: $email_from \r\n";
- $headers .= "From: {$email_from}\r\n";
- $headers .= "Reply-To: {$email_from}\r\n";
- $headers.= "MIME-Version: 1.0\r\n";
- $headers.= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
- //$header.= "X-Priority: 1\r\n";
- /*
- $headers = "From: noreply@salmaforex.com\r\n";
- $headers .= "Reply-To: noreply@salmaforex.com\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
- */
- //Send the email!
- mail($to, $email_subject, $email_body,$headers);
- //mail($to, $email_subject."(2)", $email_body );
- echo "<br/>SUCCESS";
- //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("success<pre>".print_r($_SERVER,1));
- //header('Location: thank-you.html'); //try not using header...
- //using js goto
- // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement