|
Posted by Gordon Burditt on 06/22/06 23:26
>yes I know, this has been asked many times, but I don't quite the
>answers: usu. answers are to put the redirect code -- in my case
>
> $URL =
>"out.php?msg=selected+records+have+been+deleted+from+the+database.";
> header("Location: $URL");
>
>BEFORE any HTML output (does this include 'echo' output's?)
Absolutely, it includes 'echo' output. ANY OUTPUT AT ALL is a problem,
including <html>, DOCTYPE, white space, warning messages, markers at
the beginning of UTF files.
You redirect or you present a page. You don't get to do both.
And if you try, the page you try to present won't be seen.
>but: if, like in my case, for example, I delete data (passed in req)
>from db THEN I redirect pg back to referer, how can I put redirect code
>BEFORE anything else? I have to do db stuff, disconnect from db, THEN
>do the redirect.. this is my code at then of file in question:
>
><html><head>css.. etc.. </head><body>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ THIS IS THE PROBLEM!!!
>php: do db stuff... then:
>mysql_close($conn);
>echo "<br><br><b>connection to db closed.</b><br><br><br>\n\n";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ THIS IS ALSO A PROBLEM
>$URL = "out.php?msg=selected+records+have+been+deleted+from+the+database.";
>header("Location: $URL");
>?>
></body>
></html>
>
>(this is not a serious problem since can do with JavaScript, but just
>wondering what the deal is here... in Java you do redirect with RESPONSE
>object, and you can put redirect code wherever you want.. I don't quite
>understand why this is a problem in PHP..)
PHP runs on the *SERVER*.
>(does $_RESPONSE exist in PHP? I looked here,
No.
Gordon L. Burditt
[Back to original message]
|