Page 1 of 1

Need help "traveling" between pages

Posted: Fri Jun 10, 2005 12:11 pm
by bwv2
Hi,
This may seem like an elementary problem, and I would surely be shunned from the "cool kids" group if I asked anyone I know. I have no web programming experience and am trying to teach myself php. Now that you know where I'm coming from, here is my question...

My website consists of several "steps" that gather input from the user. In each step, variables are created from the form input. In the end, all of the variables are used in math equations to produce some end result that is reported to the user. Each "step" is to be a new page, so the user is kind of led through a series of form-rittled pages ending in eudamonia and eternal happiness.

My problem arises in linking from page to page. I could construct my series of steps as one .php file consisting of many "if/elseif" steps which would, after each form submission, allow the program to proceed to the next "elseif" statement, effectively looking like new pages.

However, I would prefer to have one "if" statement in each .php file which would send a form if some variable is empty. After the form is submitted, the variable would be filled and the program would go to one "elseif" statement. Inside of this elseif statement I would like for there to be a code that sends the user to a new .php page which would act as the next step in the path to euphoria. This would allow me to have a series of .php files that would each be individual pages in my site. Each would point to a new page at its end. Pretty basic I bet, but only if you know how.

Any help would be greatly appreciated.

Posted: Fri Jun 10, 2005 5:07 pm
by pickle
So are you just wondering how to make a series of pages that forward to others? This basic format should work:

Code: Select all

<?PHP
if(isset($_POST['my_submit_button']))
{
  //process $_POST data
  header("Location: the_next_page.php");
}
else
{
  //output the form
}
?>

Posted: Fri Jun 10, 2005 11:44 pm
by webjoe
Just to add...

If you are trying to carry the values of your variables over, you can store the data into a Session, append them in your url (not recommended), or use hidden values.

how do I save to a session?

Posted: Fri Jun 10, 2005 11:49 pm
by bwv2
I would like to save my variables to a session, as mentioned in the above reply. Can someone tell me how to do that? Thanks, this is proving to be very helpful. 8O

Posted: Sat Jun 11, 2005 12:41 am
by hongco
here is the example of using session
http://us2.php.net/function.session-start