Cannot modify header information
Posted: Tue Jun 24, 2008 5:33 pm
I'm getting this error and I do not know why.
The page has both html and php code
html code then
then
then html code
Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at /home/username/public_html/page.php:5) in /home/username/public_html/page.php on line 210html code then
Code: Select all
<?php
if ($_POST)
{
if (trim($_POST['firstName'])=='' OR
trim($_POST['lastName'])=='' OR
trim($_POST['gender'])=='' OR
trim($_POST['address1'])=='' OR
trim($_POST['city'])=='' OR
trim($_POST['state'])=='' OR
trim($_POST['zipcode'])=='' OR
trim($_POST['phoneNumber'])=='' OR
trim($_POST['email'])=='' OR
trim($_POST['areaExpertise'])=='' OR
trim($_POST['yearsExperience'])=='' OR
trim($_POST['degree'])=='' OR
trim($_POST['licenseCertif'])=='' OR
trim($_POST['reasonConsult'])=='' OR
trim($_POST['compSkills'])=='' OR
trim($_POST['powerpoint'])=='' OR
trim($_POST['publicSpeaking'])=='' OR
trim($_POST['salesTraining'])=='' OR
trim($_POST['certify'])=='') {
$errors='';
if (trim($_POST['firstName'])=='')
$errors.="<li>Enter first name.</li>\n";
if (trim($_POST['lastName'])=='')
$errors.="<li>Enter your last name.</li>\n";
if (trim($_POST['gender'])=='')
$errors.="<li>Enter your gender.</li>\n";
if (trim($_POST['address1'])=='')
$errors.="<li>Enter your address.</li>\n";
if (trim($_POST['city'])=='')
$errors.="<li>Enter your city.</li>\n";
if (trim($_POST['state'])=='')
$errors.="<li>Enter your state.</li>\n";
if (trim($_POST['zipcode'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['phoneNumber'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['email'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['areaExpertise'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['yearsExperience'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['degree'])=='')
$errors.="<li>Enter your degree(s)</li>\n";
if (trim($_POST['licenseCertif'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['reasonConsult'])=='')
$errors.="<li>blah, blah, blah</li>\n";
if (trim($_POST['compSkills'])=='')
$errors.="<li>blah, blah, blahli>\n";
if (trim($_POST['powerpoint'])=='')
$errors.="<li>blah, blah, blahli>\n";
if (trim($_POST['publicSpeaking'])=='')
$errors.="<li>blah, blah, blahli>\n";
if (trim($_POST['salesTraining'])=='')
$errors.="<li>blah, blah, blahli>\n";
if (trim($_POST['certify'])=='')
$errors.="<li>You must blah, blah, blah...</li>\n";
echo "<span class=\"txtRedLg\">Errors were encountered:</span>\n";
// If there are errors display errors above the form again.
echo "<ul>\n";
echo "<span class=\"txtsmallred\">$errors</span>\n";
echo "</ul></span>\n";
}
else {
// All fields were submitted
// Redirect to a "thank you, we will be in touch" page.
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "page.php");
}
}
?>
Code: Select all
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">