Re: redirection question



On Jan 30, 7:44 pm, "GAMEchief" <SegaDra...@xxxxxxxxx> wrote:
On Jan 30, 7:10 pm, Krustov <m...@xxxxxxxxxxx> wrote:



<comp.lang.php>
<Gunnar G>
<Tue, 30 Jan 2007 23:09:59 GMT>
<bfQvh.30769$E02.12...@xxxxxxxxxxxxxxx>

Perhaps this is not the best design right now in my php script, but I've
just started with php after a long break.

The thing is that I enter a page called foo1.php, this script do some
calculations and should then send directly send the user to a page called
foo2.php together with the variables $bar and $bar2.

On the page foo1.php there will be no input or any clicking required by the
user. Just as soon as the values are calculated, it should continue.
How can I achieve this?

Is there any good valid reason why you want to redirect to foo2.php ? .

Why not just do the calculations in foo1.php and then display the
results underneath in foo1.php when they are done .

--www.phptakeaway.co.uk
(work in progress)

He's probably setting a cookie, which won't be read until a new page
is loaded.
Ya, header("Location: foo2.php"); is what you want.

Heres an all purposes function. You will run into an issue with
headers if you use any printing before you send the header information
(same with cookies and the session too), this function will send the
request as a JS redirect if the headers have already been sent.

function Redirect($location = "")
{
if (headers_sent())
{
if (!$location)
print '<script language="javascript" type="text/javascript"
window.history.go(-1)</script>';
else
print '<script language="javascript" type="text/javascript"
window.location = '.$location.'</script>';
}
else
{
if(!$location)
header("Location: " . $_SERVER["PHP_SELF"];);
else
header("Location: " . $location;);
}
}

.



Relevant Pages

  • Re: Cookie problems (simple code included)
    ... stored in a cookie and this is where the problems begin. ... before <?php as well. ... Cannot modify header information - headers already sent by ...
    (comp.lang.php)
  • Re: Cookie problems (simple code included)
    ... statement to below the php code, I still get the following error ... in a cookie and this is where the problems begin. ... Cookies are set in the headers, meaning that setcookiemust be called ... before *any* output is sent to the user (even before your DOCTYPE ...
    (comp.lang.php)
  • Re: function within echo"";
    ... session, cookie and header must ALWAYS be sent before any output, so here are some example on what you shouldn't do: ... <?PHP ... - store all output into a variable say $output, and when all headers, cookies, sessions are sent and all the output has been stored to the variable, first then do a: ...
    (alt.php)
  • Re: Include and Header(Location: ) not working together
    ... cookie - headers already sent by (output started at ... cache limiter - headers already sent (output started at ... i'm using xampp with php, ...
    (comp.lang.php)
  • Re: redirection question
    ... <Gunnar G> ... just started with php after a long break. ... Why not just do the calculations in foo1.php and then display the ... He's probably setting a cookie, which won't be read until a new page ...
    (comp.lang.php)