Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page redirect header error

Status
Not open for further replies.

Delboy14

Programmer
Jun 21, 2001
213
GB
I am trying to peform a page redirect, the code I am using is:
<code>
<?php
ob_start();
if($SubmittedDepartDate==$SubmittedReturnDate)
{header(&quot;Location: action.php&quot;);}
ob_end_flush();
?>
</code>
However I recieve the error I have listed below, does anyone know why?

Warning: Cannot add header information - headers already sent by (output started at /sites/htdocs/test.es.cib.intranet.db.com/htdocs/organisation/policies/submitted.php:8) in /sites/htdocs/test.es.cib.intranet.db.com/htdocs/organisation/policies/submitted.php on line 13
 
I have deleted this comment and the error remains the same, still complaining about line 8, which is now
{header(&quot;Location: action.php&quot;);}
 
I'm with sleipnir here, chances are you're echoing something or another before you set that header, and header's need to be the first thing output from a php script for it to work.

 
Sorry this is probably my inexperience with PHP showing. I have included the code for the page below which is quite simple, there is an echo in a php code block lower down in the page is this causing the problem?

<code>
<html>

<head>
</head>
<?php
ob_start();
if($SubmittedDepartDate==$SubmittedReturnDate)
{header(&quot;Location: action.php&quot;);}
ob_end_flush();
?>

Hello Your request has been succesfully submitted, you will be contacted in due course as to its status

<?php
$SubmittedDepartDate=$DepartMonth_Drop + $DepartDay_Drop;
$SubmittedReturnDate=$ReturnDay_Drop + $ReturnMonth_Drop;
$newline=&quot;\r\n&quot;;

$TravelRequest;
$TravelRequest[0]=$SubmittedForname;
$TravelRequest[1]=$SubmittedProject;
$TravelRequest[2]=$SubmittedCostCenter;
$TravelRequest[3]=$SubmittedRegion;
$TravelRequest[4]=$From;
$TravelRequest[5]=$To;
$TravelRequest[6]=$SubmittedDepartDate;
$TravelRequest[7]=$SubmittedReturnDate;
$TravelRequest[8]=$Purpose;
$TravelRequest[9]=$newline;

$Tab_Seperrated = implode(&quot;\t&quot;, $TravelRequest);

echo $Tab_Seperrated;

$filename = &quot;DataFiles/TravelRequests.txt&quot;;
$fd = fopen($filename, &quot;a&quot;);
$fout = fwrite($fd,$Tab_Seperrated);

fclose($fd);

?>
</body>
</html>
</code>
 
<html>

<head>
</head>

that would be your problem... move those three tags below your header() call.
 
thats great I knew about the white space but did not know it included html tags, thanks alot for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top