English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I wrote this code, the get function works as it echos the value of it on the screen. But after this i want the page to header to another page (page.php). I cant fiqure out why it doesnt send the user to page.php, ive used headers before which worked.
This is the error it says: Warning: Cannot modify header information - headers already sent by (output started at /home/sites/fatfrogip.com/public_html/yellow.php:6) in /home/sites/fatfrogip.com/public_html/yellow.php on line 29

This is the code: why doesnt it header on.?
$story = $_GET['story'];
echo "$story
";


if( $story = page.php )
{

header("location:page.php");
exit();
}
?>

2006-10-11 07:20:14 · 5 answers · asked by peter s 1 in Computers & Internet Programming & Design

5 answers

Because you are outputting text before the header(); You can not print anything even a blank line or a blank space before the header statement.

2006-10-11 07:33:39 · answer #1 · answered by Sanjay 3 · 0 0

The header declaration must be the first thing on your PHP file. If you insert text before the header is automatically sent as OK and the second header declaration give the error you describe. You can try this code instead:

$story = $_GET['story'];

if( $story = page.php )
{
header("location:page.php");
exit();
}
else
{
echo "$story
";
}

?>

2006-10-11 12:26:26 · answer #2 · answered by Diegosolo 2 · 0 0

you're utilising a Hypertext Preprocessor tag interior of Hypertext Preprocessor code already. this could artwork: additionally, that's clever to apply die() function after each header redirect because of the fact after the header function the script keeps on working (protection tip). Cheers mate!

2016-12-26 16:18:18 · answer #3 · answered by Anonymous · 0 0

Because you output things before sending headers. Headers should be sent before any output.

Also, you should replace this:

if( $story = page.php )

with this:

if ($story == 'page.php')

2006-10-14 05:33:44 · answer #4 · answered by NC 7 · 0 0

JUST REMOVE THE echo "$story
"; THEN IT WILL DEFINETLY RUN.....

2006-10-13 02:28:49 · answer #5 · answered by keshu 2 · 0 0

fedest.com, questions and answers