How can I get this redirect to work? (and this mail function)
How can I get this redirect to work? (and this mail function)
am 05.11.2007 23:37:46 von foulu0014
How do i get this to work?
header('Location: http://www.PAGE-TO-REDIRECT-TO.com/');
mail('my-email@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
?>
Re: How can I get this redirect to work? (and this mail function)
am 05.11.2007 23:56:19 von luiheidsgoeroe
On Mon, 05 Nov 2007 23:37:46 +0100, wrote:
>
> header('Location: http://www.PAGE-TO-REDIRECT-TO.com/');
> mail('my-email@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> ?>
mail('my-email@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
header('Location: http://www.PAGE-TO-REDIRECT-TO.com/');
?>
--
Rik Wasmus
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 00:03:11 von foulu0014
On Nov 5, 5:56 pm, "Rik Wasmus" wrote:
> On Mon, 05 Nov 2007 23:37:46 +0100, wrote:
> >
> > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
> > mail('my-email@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> > ?>
>
>
> mail('my-email@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
> ?>
> --
> Rik Wasmus
So that would redirect the browser and then send the IP address of the
person accessing the page to an email?
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 00:39:32 von dave
On Nov 5, 3:03 pm, foulu0...@gmail.com wrote:
> On Nov 5, 5:56 pm, "Rik Wasmus" wrote:
>
> > On Mon, 05 Nov 2007 23:37:46 +0100, wrote:
> > >
> > > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
> > > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> > > ?>
>
> >
> > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
> > ?>
> > --
> > Rik Wasmus
>
> So that would redirect the browser and then send the IP address of the
> person accessing the page to an email?
that sends an email then redirects the browser.
notice the difference?
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 01:07:45 von foulu0014
On Nov 5, 6:39 pm, dave wrote:
> On Nov 5, 3:03 pm, foulu0...@gmail.com wrote:
>
>
>
> > On Nov 5, 5:56 pm, "Rik Wasmus" wrote:
>
> > > On Mon, 05 Nov 2007 23:37:46 +0100, wrote:
> > > >
> > > > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
> > > > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> > > > ?>
>
> > >
> > > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
> > > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
> > > ?>
> > > --
> > > Rik Wasmus
>
> > So that would redirect the browser and then send the IP address of the
> > person accessing the page to an email?
>
> that sends an email then redirects the browser.
> notice the difference?
yes, thank you very much
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 03:25:41 von unknown
Post removed (X-No-Archive: yes)
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 04:44:08 von luiheidsgoeroe
On Tue, 06 Nov 2007 03:25:41 +0100, ljb wrote:
> dave.wayne@gmail.com wrote:
>> On Nov 5, 3:03 pm, foulu0...@gmail.com wrote:
>>> On Nov 5, 5:56 pm, "Rik Wasmus" wrote:
>>>
>>> > On Mon, 05 Nov 2007 23:37:46 +0100, wrote:
>>> > >
>>> > > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
>>> > > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
>>> > > ?>
>>>
>>> >
>>> > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
>>> > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
>>> > ?>
>>>
>>> So that would redirect the browser and then send the IP address of the
>>> person accessing the page to an email?
>>
>> that sends an email then redirects the browser.
>> notice the difference?
>
> You got me. What is the difference? Since mail() runs server-side, and
> header sends lines to the browser, I can't see why the order would make
> any
> difference. Both are PHP functions, and both will run regardless of the
> order in the script. Won't they?
On a header redirect, the user effectively 'aborts' as soon as he got it.
Depending on how fast the script runs/the user aborts code may or may not
be run before an untimely end. So, do all your stuff before redirecting,
or instruct PHP to ignore a user abort.
--
Rik Wasmus
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 06:07:18 von AnrDaemon
Greetings, ljb.
In reply to Your message dated Tuesday, November 6, 2007, 05:25:41,
>>> > >
>>> > > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
>>> > > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
>>> > > ?>
>>>
>>> >
>>> > mail('my-em...@website.com', 'TEST', $_SERVER['REMOTE_ADDR']);
>>> > header('Location:http://www.PAGE-TO-REDIRECT-TO.com/');
>>> > ?>
>>>
>>> So that would redirect the browser and then send the IP address of the
>>> person accessing the page to an email?
>>
>> that sends an email then redirects the browser.
>> notice the difference?
> You got me. What is the difference? Since mail() runs server-side, and
> header sends lines to the browser, I can't see why the order would make any
> difference. Both are PHP functions, and both will run regardless of the
> order in the script. Won't they?
If server didn't set up to buffer script output, headers will be sent almost
immediately.
--
Sincerely Yours, AnrDaemon
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 13:44:14 von Michael Fesser
..oO(Rik Wasmus)
>On a header redirect, the user effectively 'aborts' as soon as he got it.
A header() call doesn't sent the header out immediately. This would make
the second parameter pretty useless and would also let headers_sent()
return TRUE after the first header() call, which is not the case.
Even on a redirection header the script continues to run until it
reaches the end or an exit() call, so IMHO the OP's script should work
as expected.
Micha
Re: How can I get this redirect to work? (and this mail function)
am 06.11.2007 18:18:02 von luiheidsgoeroe
On Tue, 06 Nov 2007 13:44:14 +0100, Michael Fesser wrote:
> .oO(Rik Wasmus)
>
>> On a header redirect, the user effectively 'aborts' as soon as he got
>> it.
>
> A header() call doesn't sent the header out immediately. This would make
> the second parameter pretty useless and would also let headers_sent()
> return TRUE after the first header() call, which is not the case.
>
> Even on a redirection header the script continues to run until it
> reaches the end or an exit() call, so IMHO the OP's script should work
> as expected.
Well, that's sort of true. As soon as you do something which sends the
headers (normal output for instance) the user can abort the connection
(well, the user can abort at any time, it's just more likely it happens,
as most redirects should be without content). In this particular case it
will almost always work as expected due to the fact there's no output and
it's a tiny script which runs it course way before the HTTP connection is
aborted. On more complex scripts, which cause the user to be redirected
(or the user is fed up with your slow site and navigates away/closes the
connection), the default is the script will terminate as soon as it
realises that there's no user to give the output to anymore. See
. That's
where the very usefull function ignore_user_abort() (it's critical the
script runs it course, even without anyone to give output to) and/or
register_shutdown_function() (some things really should be cleaned up)
come into play.
For the OP it's quite academic really, under normal circumstances it will
run just fine either way around.
--
Rik Wasmus
Re: How can I get this redirect to work? (and this mail function)
am 07.11.2007 02:31:57 von unknown
Post removed (X-No-Archive: yes)