Reply to Re: redirection to another php page

Your name:

Reply:


Posted by Stephen V on 04/02/06 22:18

thanks alot for explaining so well.
"J.O. Aho" <user@example.net> a ιcrit dans le message de news:
49abb5Fnm14hU1@individual.net...
> Stephen V wrote:
>> I am afraid I don't understand.
>
> If you use header(), you aren't allowed to make any output of any kind
> before the header() is used
>
> --- not working file 1 ---
>
> <?PHP
> header("Location: http://examplet.net");
> ?>
> --- eof ---
>
> --- not working file 2 ---
> <?PHP
> echo $_POST['data']."<br>\n";
> header("Location: http://examplet.net");
> ?>
> --- eof ---
>
> file 1 has a white space in the beginning (a return before the '<?PHP'),
> this will result in that the header() won't work as it has to be sent
> before any output.
>
> file 2 has an echo of a variable that may be sent to the page, as this is
> output, it will prevent the header() to be sent as it should.
>
>
> --- working file 3 ---
> <?PHP
> if(empty($_POST['data'])) {
> header("Location: http://examplet.net");
> exit;
> }
> echo "The $_POST data was: ".$_POST['data']."<br>\n";
> ?>
> --- eof ---
>
> file 3 has no output before the header() is used and the header() is in
> this case in a if-statement which makes it not always to be used, if the
> variable sent to the page isn't empty then an output is made but no
> header() sent.
>
> Your original code had a none working header, should have looked like
> this:
> header("Location: http://127.0.0.1/add_task.php?request_name=$req_name");
>
> You can see my previous post, lines that are comments are unmodified rows
> of your original code, rows that aren't comments are changes needed to
> make the header() to work.
>
>
> //Aho

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация