SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | if(!isset($_POST['submit'])) | |
3 | { | |
4 | //This page should not be accessed directly. Need to submit the form. | |
5 | - | //echo "error; you need to submit the form!"; |
5 | + | echo "error; you need to submit the form!"; |
6 | - | header("location:index.html");//you can change later |
6 | + | //header("location:index.html");//you can change later |
7 | } | |
8 | ||
9 | - | echo '<pre>'.print_r($_POST,1); exit; //comment this line to continue |
9 | + | //echo '<pre>'.print_r($_POST,1); exit; //comment this line to continue |
10 | $name = $_POST['name'];//remember.. name not using capitalize | |
11 | $email_address = $_POST['email_address']; | |
12 | $phone = $_POST['phone']; | |
13 | $comments = $_POST['comments']; | |
14 | // 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? | |
15 | //Validate first | |
16 | if(empty($name)||empty($email_address)) //$visitor_EMAIL_ADDRESS is not valid.. but you should check this should type $EMAIL_ADDRESS | |
17 | { | |
18 | echo "Name and email are mandatory!"; | |
19 | //the email will not be empty... but you need to check if the email is valid | |
20 | // http://stackoverflow.com/questions/12026842/how-to-validate-an-email-address-in-php | |
21 | exit; | |
22 | } | |
23 | ||
24 | $email_from = '[email protected]';'[email protected]';'[email protected]';//<== Put your email address here | |
25 | $email_subject = "New Form submission"; | |
26 | $email_body = "You have received a new message from the user $name.\n". | |
27 | "email address: $visitor_email_address\n". | |
28 | "Here is the COMMENTS:\n $comments". | |
29 | ||
30 | $to = "[email protected]";//<== Put your email address here | |
31 | $headers = "From: $email_from \r\n"; | |
32 | ||
33 | //Send the email! | |
34 | mail($to,$email_subject,$email_body,$headers); | |
35 | echo "<br/>sending email"; | |
36 | //this email function not always work as we wanted | |
37 | ||
38 | /* | |
39 | for first.. hope this mail work | |
40 | if not.. search how to using SMTP or other ways to email... | |
41 | */ | |
42 | - | header('Location: thank-you.html'); //try not using header... |
42 | + | |
43 | die("success"); | |
44 | //header('Location: thank-you.html'); //try not using header... | |
45 | //using js goto | |
46 | // http://stackoverflow.com/questions/9803978/javascript-method-to-navigate-to-other-url | |
47 | ||
48 | ||
49 | ||
50 | ?> |