Log in

View Full Version : add up forms?



jimbomac
08-31-2006, 09:53 PM
Need Help.....!

I Have Created 4 .html Forms In Each One Of Them There Is Items To Be Selected.

I Need The Code That Will Add Up Those Selected Items In The 4 .html Forms Into A A New Window For People To Sumnit What They Selected..



Please Rsvp Soooooon!!!!

alexjewell
08-31-2006, 11:02 PM
You'll need to change those four files to .php. Or at least the last 3. The first one can stay HTML, but I wouldn't recommend it.

Here's what you'll need to do:

the first form must submit, or "action" to the second form. The method must = "post".

Now, let's say you give one selection the name "selection1", on the second form, you'll use this code:



<?php

$selection1 = $_POST['selection1'];

?>


Now, for however many selections there are, just make new ones. You can change the names to whatever, just make sure they match up.

Then, you'll create hidden inputs with this information:



<input type="hidden" name="selection1" value="<?=$selection1 ?>" />


And for every selection, add a new input line like that, just change the names.

Now, keep carrying these over and over to the next pages, by using the $_POST method I showed you.

Make sense?

jimbomac
08-31-2006, 11:08 PM
and the final page where everything is add up....? what's de code? i mean

xx1.php ....go to ....... xx2.php go to.....xx3.php= ?

where "?" is the form...

alexjewell
09-01-2006, 12:31 AM
ok, let's say we have four pages: form1.php, form2.php, form3.php, and form4.php:

form1.php just has the form, we submit selections named selection1 and selection2.

so then, form2.php has this code:



<?php

$selection1 = $_POST['selection1'];
$selection2 = $_POST['selection2'];

?>


then, you just put the info into hidden inputs, and this is still form2.php:



<input type="hidden" name="selection1" value="<?=$selection1 ?>" />
<input type="hidden" name="selection2" value="<?=$selection2 ?>" />


Make sure the php code is at the top of the page.
Add the other selections, selection3 and selection4 for form2.php then submit the form to form3.php.

form3.php would be like this...say there's 2 more selections on form3, selection5 and selection6:



<?php

$selection1 = $_POST['selection1'];
$selection2 = $_POST['selection2']; //we carry the other two over from form1.php

$selection3 = $_POST['selection3'];
$selection4 = $_POST['selection4']; //and we carry the two over from form2.php

?>


then, we do the inputs again:



<input type="hidden" name="selection1" value="<?=$selection3 ?>" />
<input type="hidden" name="selection2" value="<?=$selection4 ?>" />


and we do this for the other page(s)...

do you get the pattern?

jimbomac
09-01-2006, 04:23 PM
i really appreciate the time you are taking to help me out...
ok.....let me understand...

form1.php, form2.php, form3.php, and form4.php are the pages where :
people click on a button "next" after choosing items from form1.php, will carry the info to form2.php.....3 and 4 right? and at the end everything that has been selected will add up to the master "submit_info.php"