I keep getting the warning "Warning: Cannot modify header information - headers already sent by (output started at /home/camelarc/public_html/contactform.php:11) in /home/camelarc/public_html/contactform.php on line 33"
The warning occurs after i fill out a form on my website and press submit. The warning appears, but the php file still sends an email to the specified account.
The php file is as follows:
<?php
if(isset($_POST['submit'])) {
$to="customerservice@camelarches.com";
$subject="Customer Feedback.";
// data the visitor provided
$name_field=filter_var($_POST['name']);
$address_field=filter_var($_POST['address']);
$city_field=filter_var($_POST['city']);
$state_field=filter_var($_POST['state']);
$zip_field=filter_var($_POST['zip']);
$telephone_field=filter_var($_POST['telephone']);
$email_field=filter_var($_POST['email']);
$comment=filter_var($_POST['comment']);
//constructing the message
$body="From: $name_field\n\n E-Mail: $email_field\n\n Address: $address_field\n\n City: $city_field\n\n State: $state_field\n\n Zip: $zip_field\n\n Telephone: $telephone_field\n\n Message:\n\n $comment";
mail($to, $subject, $body);
// redirect to confirmation
header('location:http://www.camelarches.com/');
exit;
}else{
// handle the error somehow
}
?>
I would really appreciate it if anyone could help me solve my problem. The warning occurs after i fill out a form on my website and press submit. The warning appears, but the php file still sends an email to the specified account.