i have this if statement that returns a quote based on user input in an html form:
if (($_POST['age'] >= 18) && ($_POST['age'] <= 25) && ($_POST['sex'] =="male"))
$quote=31.44;
elseif (($_POST['age'] >= 18) && ($_POST['age'] <= 25) && ($_POST['sex'] =="female"))
$quote=44.65;
elseif (($_POST['age'] >= 26) && ($_POST['age'] <= 30) && ($_POST['sex'] =="male"))
$quote=35.91;
is there a way to redirect someone to a different php page if they enter an age 65-80?
Thanks!
if statement return a new php page?
Moderator: General Moderators
-
ringartdesign
- Forum Newbie
- Posts: 21
- Joined: Wed Sep 10, 2008 10:11 am
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: if statement return a new php page?
Take a look at meta refresh http://webdesign.about.com/od/metatagli ... 80300a.htm
Re: if statement return a new php page?
Code: Select all
header("location: WHERE_YOU_WANT_THEM_TO_GO.php");
- novice4eva
- Forum Contributor
- Posts: 327
- Joined: Thu Mar 29, 2007 3:48 am
- Location: Nepal
Re: if statement return a new php page?
The one and only problem with header is that it returns error in case you have anything echoed before it, even a space would. I like header if it didn't have that short come, so again there is javascript solution: but who knows who have their javascript disabled!! Hopefully if they are not, do something like this:
Code: Select all
elseif (($_POST['age'] >= 65) && ($_POST['age'] <= 80))
{
echo '<meta HTTP-EQUIV=\"refresh\" content=".$refreshTime.";url=\"".$url."\">';//WHERE $url is the page you want to redirect, $refreshTime is the time by which you delay the redirection, exactly what aceconcepts suggested
/* OR YOU COULD OPEN A NEW PAGE*/
echo '<script>window.open("'.$url.'");</script>';
/* OR YOU COULD OPEN IT IN THE SAME PAGE AS*/
echo '<script>window.location.href="'.$url.'";</script>';
}