Hi guys I want to redirect to a page from an if statement i.e without the user doing anything
if condition==a then
got to page
else
got to other page
end if
any help would be great!
Hi guys I want to redirect to a page from an if statement i.e without the user doing anything
if condition==a then
got to page
else
got to other page
end if
any help would be great!
<?php
if( $something ){
Header("Location: somewhere.php");
} else {
Header("Location: [http://www.google.com](http://www.google.com)");
}
?>
if (conditiona) {
include ('page_a');
}
else {
include ('page_b');
]
of course thats not redirecting but it is including the page based on an if
hi ,
There's plenty of ways, some more 🙂
PHP + JavaScript ways :
if($flag == 'blabla')
print "<script language="Javascript">document.location.href='page_a.php' ;</script>";
else
print "<script language="Javascript">document.location.href='page_b.php' ;</script>";
if($flag == 'blabla')
print "<script language="Javascript">document.location.replace('page_a.php');</script>";
else
print "<script language="Javascript">document.location.replace('page_b.php');</script>";
those can work at any level in the script, in any case but JavaScript support must be activated in the client.
and another way is to use meta tags
if($flag == "something") {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=page_1.php\">";
} else {
echo "<meta http-equiv=\"refresh\" content=\"0;URL=page_2.php\">";
}
This way can be altered in how long it takes and it won't be affected by the headers, so it can be placed anywhere
Hi evereybody,
Hi Vincent
thanks! 🙂
to me ,yours and Typhon's one are the ones wich have fewest inconvenients 🙂
anyone else? 🙂
choosing one depends on the circumstances in fact.
Thanks guys really appreciate the help worked a charm-
im using vincents! 😁