I've worked with ASP for a number of years and have just made the switch to PHP because,well, it's better, but anyway... in ASP there's a method you can use to transfer output to another page ie.:
Response.Redirect "http://......"
This sends the page listed in the argument to the client's browser.
Is there an equivalent to this in PHP? I've tried using headers ie:
header (location: "http://.....");
But that only works at the beginning of the page. I want to be able to move the user to a page based on a conditional statement ie.
If (blah){
then load this page...
} else{
load this page.....
}
Any help would be great!
Thanks
1/2abag
simple question
Moderator: General Moderators
not quite. It only works before any content-output.But that only works at the beginning of the page.
As long as you don't output anything (see also Sticky: Before Post Read: Warning: Cannot add header information) you can use header('location:....'); anywhere.
also take a look at the include(), require(), include_once() and require_once() manual-pages. Maybe even virtual()
I use the Include or the include once. For example this is what i use for access to some of my games.
First off, when they sign into my page one of the variables that is checked and sessioned is a one i give the name of $fast. If the $fast=y then then are do not have to have a starting password emailed to them but rather use their reged password.
<HR>
if ($fast==Y) {
include ("fast/gamea.php");
} // end of the fast area.
else
{
include ("normal/gamea.php");
}
First off, when they sign into my page one of the variables that is checked and sessioned is a one i give the name of $fast. If the $fast=y then then are do not have to have a starting password emailed to them but rather use their reged password.
<HR>
if ($fast==Y) {
include ("fast/gamea.php");
} // end of the fast area.
else
{
include ("normal/gamea.php");
}