mystic_bovine Posted September 16, 2008 Share Posted September 16, 2008 Here's the scenario: A survey that asks your birth date. Once it figures out your age it then goes to a different page depending on your age and opens up another survey. What is the best way to do this with PHP? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Fadion Posted September 16, 2008 Share Posted September 16, 2008 One is using the header() function. But beware of the "headers already sent" error which is explained in this sticky. <?php header('Location: somepage.php'); ?> Alternatively, you can use meta refresh. <?php echo '<meta http-equiv="refresh" content="0;url=somepage.php">'; ?> Place one of those codes directly where in your script you want the user to be redirected. To save the age of the user, you can use sessions: <?php session_start(); //start the session data $age = $_POST['age']; //supposing this comes from an input $_SESSION['age'] = $age; //set the session which can be used globally in all your pages ?> Quote Link to comment Share on other sites More sharing options...
mystic_bovine Posted September 16, 2008 Author Share Posted September 16, 2008 Gawd. So simple. Thanks! I got stuck on the header() function. But the meta refresh worked great. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.