SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | $errors = ''; | |
| 3 | $myemail = '[email protected]';//<-----Put Your email address here. | |
| 4 | $bccemail = '[email protected]';//<-----Put Your email address here. | |
| 5 | if(empty($_POST['name']) || | |
| 6 | empty($_POST['email']) || | |
| 7 | empty($_POST['message'])) | |
| 8 | {
| |
| 9 | $errors .= "\n Error: all fields are required"; | |
| 10 | } | |
| 11 | ||
| 12 | $name = $_POST['name']; | |
| 13 | $email_address = $_POST['email']; | |
| 14 | $message = $_POST['message']; | |
| 15 | - | $message=stripslashes($message); |
| 15 | + | // don't use stripslashes() because magic_quotes_gpc is deprecated |
| 16 | // In case any of our lines are larger than 70 characters, we should use wordwrap() | |
| 17 | $message = wordwrap($message, 70, "\r\n"); | |
| 18 | ||
| 19 | if (!preg_match( | |
| 20 | "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
| |
| 21 | $email_address)) | |
| 22 | {
| |
| 23 | $errors .= "\n Error: Invalid email address"; | |
| 24 | } | |
| 25 | ||
| 26 | if( empty($errors)) | |
| 27 | {
| |
| 28 | $to = $myemail; | |
| 29 | $email_subject = "Contact form submission: $name"; | |
| 30 | $email_body = "You have received a new message. ". | |
| 31 | - | $headers = "From: $myemail\n"; |
| 31 | + | |
| 32 | - | $headers .= "Reply-To: $email_address"; |
| 32 | + | |
| 33 | $headers = "From: $myemail" . "\r\n"; | |
| 34 | $headers .= "Reply-To: $email_address" . "\r\n" .; | |
| 35 | $headers .= "Bcc: $bccemail"; | |
| 36 | ||
| 37 | mail($to,$email_subject,$email_body,$headers); | |
| 38 | //redirect to the 'thank you' page | |
| 39 | header('Location: thank_you_for_contacting_us.php');
| |
| 40 | } | |
| 41 | ?> |