[thelist] newbie PHP question...header:location();

Warden, Matt mwarden at odyssey-design.com
Tue Aug 15 18:10:15 CDT 2000


> if you want to use php's header tag, that needs to come before *any*
> code on the page.

I know what you mean, but this seems a little misleading. It has to be in
your script before HTML or text that is written to you output stream.
Basically, you have to get it in there before HTTP headers are sent, which
is where the Location header resides.

> otherwise it won't work.  in order to get your code to redirect after
> it sends the e-mail message (which is what i'm assuming you want your
> code to do), use the following:
>
> $url_success = "http://www.neoncowboy.com/contact-thanks.html;
>
> echo("<meta http-equiv = refresh content=0;url=".$url_success.">");
> mail($to, $subject, $messagemer, $mailheaders);
>
> i use this code on all of my sites and it works without a hitch.  let
> me know if you have any problems.

You can do it this way, but why not do a server-side redirect:

mail($to, $subject, $messagemer, $mailheaders);
header("Location", $url_success);

--
mattwarden
mattwarden.com






More information about the thelist mailing list