Re: Re-directing
| From: | Martin Clifford | Date: | Wed, 24 Jul 2002 15:04:34 +0000 |
| Subject: | Re: Re-directing | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-109317@lists.php.net to get a copy of this message | ||
Awesome! Learn something new everyday!
That's why I love this list :o)
Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/
>>> "Chris Sharkey" <csharkey@ozstays.com> 07/24/02 11:01AM >>>
Well you can actually,
If you start your script IMMEDIATELY (well before you output anything) with:
<?php
ob_start();
This will buffer output so you can use your header anywhere in your script
eg
header("location.php");
exit;
and then if you weren't redirected then you send the output with
ob_end_flush();
Chris.
----- Original Message -----
From: "Martin Clifford" <MLC1@nrc.gov>
To: <php-general@lists.php.net>; <Mark.Roberts@williams.com>
Sent: Thursday, July 25, 2002 12:47 AM
Subject: Re: [PHP] Re-directing
PHP redirects using the header() function, but it's not very useful if
information has already been sent to the browser. ANY information,
including a hard return. So if you have a login script, you would start
your session, register any variables, then redirect.
<?php header("Location: index.php"); ?>
That would do the trick. But like I said, once the parser begins to write
HTML to the browser, then you can no longer send HTTP headers.
Martin Clifford
Homepage: http://www.completesource.net
Developer's Forums: http://www.completesource.net/forums/
>>> "Roberts, Mark" <Mark.Roberts@williams.com> 07/24/02 10:28AM
>>> >>>
Is there a way to redirect to a different script in PHP? I call it
redirecting, but can't find it in the documentation using that track.
I have a script...that if a certain criteria is met, I want to load a
different script. Haven't been able to figure that out yet. I have gotten
about it by conditionally executing a location.href in javascript. It works,
but would like to know how to do it in PHP.
~Thanks.
Mark Roberts
Sr. Systems Analyst
LanApps/Web Development
The Williams Information Services Corporation
918-573-1706
mark.roberts@williams.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php