equal
deleted
inserted
replaced
|
1 <?php |
|
2 //If the form is submitted |
|
3 if(isset($_POST['submit'])) { |
|
4 |
|
5 //Check to make sure that the name field is not empty |
|
6 if(trim($_POST['contactname']) == '') { |
|
7 $hasError = true; |
|
8 } else { |
|
9 $name = trim($_POST['contactname']); |
|
10 } |
|
11 |
|
12 //Check to make sure that the subject field is not empty |
|
13 if(trim($_POST['subject']) == '') { |
|
14 $hasError = true; |
|
15 } else { |
|
16 $subject = trim($_POST['subject']); |
|
17 } |
|
18 |
|
19 //Check to make sure sure that a valid email address is submitted |
|
20 if(trim($_POST['email']) == '') { |
|
21 $hasError = true; |
|
22 } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { |
|
23 $hasError = true; |
|
24 } else { |
|
25 $email = trim($_POST['email']); |
|
26 } |
|
27 |
|
28 //Check to make sure comments were entered |
|
29 if(trim($_POST['message']) == '') { |
|
30 $hasError = true; |
|
31 } else { |
|
32 if(function_exists('stripslashes')) { |
|
33 $comments = stripslashes(trim($_POST['message'])); |
|
34 } else { |
|
35 $comments = trim($_POST['message']); |
|
36 } |
|
37 } |
|
38 |
|
39 //If there is no error, send the email |
|
40 if(!isset($hasError)) { |
|
41 $emailTo = get_option_tree( 'contact_page_email' ); /*Put your own email address here*/ |
|
42 $body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments"; |
|
43 $headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email; |
|
44 |
|
45 mail($emailTo, $subject, $body, $headers); |
|
46 $emailSent = true; |
|
47 } |
|
48 } |
|
49 ?> |