Page 1 of 1

Header Problem

Posted: Mon Nov 21, 2005 3:08 am
by keveh
I have an application for for a website I am constructiong at the moment, and I am having a problem with the headers. I am getting the error message:

Warning: Cannot modify header information - headers already sent by (output started at /content/EnterpriseHostPlus/g/b/gb-energy.com/web/test/submitted.php:1) in /content/EnterpriseHostPlus/g/b/gb-energy.com/web/test/submitted.php on line 81

I can understand what it's saying, but I don't think that it should be saying it.

Here is my code, but shortened down.

Code: Select all

<?php
	if (isset($actionflag) && $actionflag == "grant"){
		
	if(!empty($_POST[firstname]) && !empty($_POST[surname]) && !empty($_POST[houseno]) && !empty($_POST[postcode]) && !empty($_POST[telnumber])) {

	// mail message
	$msg = "<img src=http://www.gb-energy.com/test/images/logo.png><br><br>";

	$msg .= "<font face=Arial size=3><b>Application Form</b></font><br><br>";

// Personal Details
	$msg .= "<table width=600 border=0><tr><td width=50% valign=top>";
	$msg .= "<font face=Arial size=2><b>Personal Details</b><br><br>";
	$msg .= "Name:<br>&nbsp;&nbsp;&nbsp;&nbsp;$_POST[title] $_POST[firstname] $_POST[middle] $_POST[surname]<br><br>";
	$msg .= "Date of Birth:<br>&nbsp;&nbsp;&nbsp;&nbsp;";
	$msg .= "$_POST[day] / $_POST[month] / $_POST[year]<br><br>";
	$msg .= "Address:<br>&nbsp;&nbsp;&nbsp;&nbsp;";
	$msg .= "$_POST[houseno] <br> &nbsp;&nbsp;&nbsp;&nbsp;$_POST[address1] <br> &nbsp;&nbsp;&nbsp;&nbsp;$_POST[address2] <br> &nbsp;&nbsp;&nbsp;&nbsp;$_POST[city] <br> &nbsp;&nbsp;&nbsp;&nbsp;$_POST[postcode]<br><br></td>";

// Contact Details
	$msg .= "<td width=50% valign=top>";
	$msg .= "<font face=Arial size=2><b>Contact Details</b><br><br>";	
	$msg .= "Telephone Number:<br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[telnumber]<br><br>";
	$msg .= "Best Contact Time:<br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[time]<br><br>";
	$msg .= "E-mail Address:&nbsp;&nbsp;&nbsp;&nbsp; $_POST[email]<br></td></tr></table><br>";

	$msg .= "<table width=600 border=0 cellspacing=5 cellpadding=5><tr>";
	$msg .= "<td width=50% valign=top>";

// Grant information
	$msg .= "<font face=Arial size=2><b>Grant Information</b><br><br>";
	$msg .= "Benefits for householders aged 60 or over:<br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[oversixty]<br><br>";
	$msg .= "Benefits for householders who have a child under 16 or are pregnant:<br> &nbsp;&nbsp;&nbsp;&nbsp; $_POST[childpregnant]<br><br>";
	$msg .= "Benefits for householders in receipt of one or more of the following benefits:<br>&nbsp;&nbsp;&nbsp;&nbsp;";
	$msg .= "$_POST[receiptbenefit]<br><br><br>";
	$msg .= "</td>";

// Home Information
	$msg .= "<td width=50% valign=top> <font face=Arial size=2> <b>Home Information</b><br><br>";
	$msg .= "Type of Property: <br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[property]<br><br>";
	$msg .= "Approximate year built: <br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[yearbuilt]<br><br>";
	$msg .= "Existing Heating:<br>";

	if ( $_POST[heating] == "Other" ){
		$msg .= "Other - $_POST[heatingother]<br><br>";
	} else {
		$msg .= "&nbsp;&nbsp;&nbsp;&nbsp; $_POST[heating]<br><br>";
	}

	$msg .= "Approximate year installed: <br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[yearinstalled]<br><br>";

	if ( $_POST[insulation] == "Other" ){
		$msg .= "&nbsp;&nbsp;&nbsp;&nbsp; Other - $_POST[insother]<br><br>";
	} else {
		$msg .= "&nbsp;&nbsp;&nbsp;&nbsp; $_POST[insulation]<br><br>";
	}

	$msg .= "</td></tr></table>";

// General Information

	$msg .= "<font face=Arial size=2><b>General Information</b></br><br>";
	$msg .= "Where did you hear about us?<br>&nbsp;&nbsp;&nbsp;&nbsp; $_POST[marketing]<br><br>";
	$msg .= "I am Interested in:<br> $_POST[interested]";


	// mail properties

	$recipient = "kevin.williams@incitodesign.com";
	$subject = "GB Energy Enquiry Form";
	$mailheaders = "MIME-Version: 1.0\r\n";
	$mailheaders .= "Content-type: text/html; charset=iso-8859-1\r\n";
	$mailheaders .= "Content-Transfer-Encoding: 7bit\r\n";
	$mailheaders .= "From: \n";
	$mailheaders .= "Reply-To: $_POST[email]";

	//sending the mail

	mail($recipient, $subject, $msg, $mailheaders);
	
	header("location: thanks.html" );

	} else {

?>		

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> GB Energy Test </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link rel="stylesheet" type="text/css" href="gbenergy.css" />
</HEAD>

<BODY>


lots and lots of html here


</BODY>
</HTML>

<?php
	
	}	

}
?>

I can see that it's saying the header is already set in the php code, but it shouldn't be even getting to the HTML code if the application form has been completed correctly. The application form is fine, and I recieve that all correctly, it just wont redirect to the right place.

Posted: Mon Nov 21, 2005 3:27 am
by JayBird
mkae usre there is no whitespace before the php code or any other invisible content

Posted: Mon Nov 21, 2005 3:29 am
by keveh
Holy crap.

I had a single space before my <?php

Thanks!