Click to See Complete Forum and Search --> : Real Newbie needing help with passing variables in form from page to page


scofansnags
08-30-2005, 07:46 AM
I don't know anything about PHP, but I have a form that I would like to divide into 4 pages with 50 quesions on each page. I don't need help setting up the form, but I need help with how to pass the variables on from the first page to the second....first and second page to the 3rd and so on using ?hidden fields? In the end, on the last page when the visitor hits the Submit button, everything from all the pages will be sent to me at one time.

This is what I have:
<form method=post name="form1" action="http://us.1.p2.webhosting.yahoo.com/forms?login=myusername">

Could someone help me do this? Please explain and lay it out as simply as possible.

aznchong91
08-30-2005, 08:54 AM
You are really asking a lot. I don't think many people would bother to write down the code and explain it. Basically what you could do is have hidden fields, OR a database where you put the information they send OR (possibly) cookies and sessions.

scofansnags
08-30-2005, 09:43 AM
I don't really need it explained. If someone could just tell me "what to put where." Like a parrot...I can learn by mimicking.

Scofansnags

NogDog
08-30-2005, 01:17 PM
At the top of each page in the form sequence and the final form-handling page, put this at the very top of the script:

<?php
session_start();
if(isset($_POST)
{
foreach($_POST as $key => $value)
{
$_SESSION[$key] = $value;
}
}
elseif(isset($_GET))
{
foreach($_GET as $key => $value)
{
$_SESSION[$key] = $value;
}
}
?>

All form values will now be available in the $_SESSION array. Note that all form fields must have unique names even if on different pages in the sequence.