Bob Bobinson
New member
I get this annoying error message when a form is sent:
Warning: Cannot modify header information - headers already sent by (output started at /public_html/email.php:65) in /public_html/email.php on line 93
The email still sends, but the error message appears. Here is my PHP code:
<?php
$to = "[email protected]" ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: [email protected]";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.YourDomain.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify [email protected]"; }
}
}
?>
Hi,
Thanks very much for the reply.
I am sorry, but I am very new to PHP, and I don't quite understand what you mean. Below is most of my web page which is causing the problem. Once again, thanks very much.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="googlebot" content="nosnippet">
<meta name="robots" content="noindex, nofollow" />
<meta name="robots" content="noarchive" />
<meta hhtp-equiv="Content-Script-Type" content="text/javascript">
<meta hhtp-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title> Thank you for your tips!</title>
<link rel="stylesheet" type="text/css" media="screen" href="styles.css" />
<link rel="stylesheet" type="text/css" media="screen" href="button.css" />
<link rel="stylesheet" type="text/css" media="screen" href="rounds.css" />
<link rel="sty
Thanks for the reply.
Would it be possible for you to fix my code up please?
I'm sorry, but I'm really new to this but I need it done soon,
Thanks,
Bob
Warning: Cannot modify header information - headers already sent by (output started at /public_html/email.php:65) in /public_html/email.php on line 93
The email still sends, but the error message appears. Here is my PHP code:
<?php
$to = "[email protected]" ;
$from = $_REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Web Contact Data";
$fields = array();
$fields{"Name"} = "Name";
$fields{"Company"} = "Company";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"list"} = "Mailing List";
$fields{"Message"} = "Message";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: [email protected]";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
if($name == '') {print "You have not entered a name, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.YourDomain.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify [email protected]"; }
}
}
?>
Hi,
Thanks very much for the reply.
I am sorry, but I am very new to PHP, and I don't quite understand what you mean. Below is most of my web page which is causing the problem. Once again, thanks very much.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="googlebot" content="nosnippet">
<meta name="robots" content="noindex, nofollow" />
<meta name="robots" content="noarchive" />
<meta hhtp-equiv="Content-Script-Type" content="text/javascript">
<meta hhtp-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title> Thank you for your tips!</title>
<link rel="stylesheet" type="text/css" media="screen" href="styles.css" />
<link rel="stylesheet" type="text/css" media="screen" href="button.css" />
<link rel="stylesheet" type="text/css" media="screen" href="rounds.css" />
<link rel="sty
Thanks for the reply.
Would it be possible for you to fix my code up please?
I'm sorry, but I'm really new to this but I need it done soon,
Thanks,
Bob