Forum Moderators: coopster
1) I have a form with a list of about 100 products that are listed with quantity text-boxes beside them. Users can fill out the number of each product they want and hit Submit.
2) They are then taken to a waver form that they have to accept.
3) After they click Accept they are faced with a form for contact information. They fill that out and click Submit.
4) Here is where it all happens. All information has to be displayed here. I would like to list all the products from the first page ( could be up to 200 products) and their contact information from page 3rd page. The problem is that I have lost all the information.
I don't really want to use sessions because there could be lots of products (up to 200).
I prefer using:
foreach($_POST as $name=>$value){
//skip the submit button
if($name == "submit"){continue;}
echo "<li>$name: $value<br>";
}
Is there any suggestions?
Kam
It's a bit of a kludge, but it works. It would be easier to store the values in a database (as dc suggested) or flat file. Easier from a coding perspective, as I have to make sure these values are in every POST, which means adding extra code. The second page contains 4 different forms (Previous, Next, Add, and Accept), so I've included those values in each form - even though they may not be relevant to that form. POST'ing just once without them means losing everything.
One option I've considered is to write a class that will 'hold' my values, but really, it would be much simpler to store these values in a table and retrieve them as needed.
The second page of my process can accept an unlimited number of items, and those are stored in a transaction table. Yeah, I got smarter as the process got more involved...
This example is the basics, testing to see if a POST array element is set, then assign it's value to a new variable.
if (isset($_POST["USERID"]))
{
$wkUSERID = $_POST["USERID"];
}
Then in each form I add an input type for everything that will be passed along to the next page, just like it was done on the first form.
<input type="hidden" name="USERID" value="<?php echo $wkUSERID;?>">
I've got to admit, even handling as few as 30 variables like this can be a headache. If you can't access a database table your next best option would be to write them to a file and read that file back in the final process. I say this only because of the number of variables under consideration.