View Full Version : How to submit html form info to sessions
Doomtomb
12-10-2008, 05:22 AM
I have an HTML form with various buttons and drop boxes and I need help figuring out how to put these variables to sessions and display the info on the next page. I've worked with HTML and PHP before but I've never done this before, I just need an explanation and example code to work with.
Thanks so much!
Doomtomb
12-10-2008, 05:48 PM
39 views, no replies...
Snookerman
12-10-2008, 08:46 PM
Try posting the code you have so far.
Doomtomb
12-15-2008, 07:23 AM
The code is very long and frankly complex. This form is intended for the user to configure a custom computer. I would like to have the user complete the form and then hit a Submit button which would store the form information in sessions or cookies, like a shopping cart. And be able to display the info that they put in this form on a page for them to review.
Sounds tough, but I would appreciate any help! I need to get the ball rolling on this project. Here is some sample code:
<form name="Build" action="intel_customdesktop.php" method="post">
<u>Mid-towers:</u><br>
<input type="radio" name="Case" value="antec_900" onclick="onClickItem(1,1); updateSummary('summary_case','Antec 900'); document.getElementById('image_case').src='images/antec_900.jpg'">
Antec 900<span id='PriceLabel_1_1'> <b>[ +0 ]</b></span><br>
That's an example of one of the options on the case category. Here I use radio buttons.
<div id="Group1">
<div id="Choice2-1">
<input type="radio" name="PowerSupply" id="ch2-1" onclick="Hierarchy(500); Reset(1,this.parentNode);">500W
<div id="sub_ch2-1" style="visibility: hidden; display: none;">
<input type="radio" name="500w" id="PSU1" onclick="onClickItem(2,1); updateSummary('summary_powersupply','500W [Modular] Antec Neo Power'); document.getElementById('image_psu').src='images/antec_500w.jpg'" Checked>
<span class="important">[Modular]</span> Antec Neo Power<span id='PriceLabel_2_1'></span><br>
<input type="radio" name="500w" id="PSU2" onclick="onClickItem(2,2); updateSummary('summary_powersupply','500W Apevia Java'); document.getElementById('image_psu').src='images/apevia_500w.jpg'">
Apevia Java<span id='PriceLabel_2_2'> <b>[ -35 ]</b></span><br>
<input type="radio" name="500w" id="PSU3" onclick="onClickItem(2,3); updateSummary('summary_powersupply','500W Cooler Master eXtreme'); document.getElementById('image_psu').src='images/cooler master_500w.jpg'">
Cooler Master eXtreme<span id='PriceLabel_2_3'> <b>[ -30 ]</b></span><br>
<input type="radio" name="500w" id="PSU4" onclick="onClickItem(2,4); updateSummary('summary_powersupply','500W Silverstone ST50F'); document.getElementById('image_psu').src='images/silverstone_500w.jpg'">
Silverstone ST50F<span id='PriceLabel_2_4'> <b>[ -10 ]</b></span><br>
</div>
</div>
This one above is an example of grouped radio buttons. The user clicks on the top radio button, in this case, 500W and then shows the next block of radio buttons which is the brand.
<div id="Group3">
<div id="Choice8-1">
<input type="radio" name="VideoCard" id="ch8-1" onclick="Reset(3,this.parentNode); ChangeRadio(8.1);" Checked>Nvidia
<div id="sub_ch8-1" style="visibility: visible; display: block;">
<select width="450" id="8.1" onchange="Hierarchy(8.1);">
<option id="GPU1" value="GPU1" onclick="onClickItem(8,1); updateSummary('summary_videocard','8800GT'); document.getElementById('image_videocard').src='images/nvidia_8800gt.jpg'; optionFixNvidia('GPU',8,1);">GeForce 8800GT - 512MB --- [ -80 ]</option>
That's an example of the drop box I use paired with radio button. The user clicks radio button Nvidia or ATI and then chooses from a drop box the actual card.
<input type="checkbox" name="WirelessGRouter" onclick="onCheckItem(this,41,2);" onmouseover="document.getElementById('image_wireless').src='images/linksys_wirelessgrouter.jpg'">
Linksys WRT54G2 Wireless-G Broadband Router<span id='PriceLabel_41_2'> <b>[ +60 ]</b></span><br>
Finally, this is one of the checkboxes I have for completely optional things.
I know this is alot but most of the junk here is little onclick javascripts to update price and summary.
Thanks for your time and help me please! :)
Doomtomb
12-17-2008, 12:53 AM
Getting started would help, like how to make a session....
Doomtomb
12-19-2008, 07:40 AM
Still looking for assistance
JasonDFR
12-20-2008, 09:40 AM
<?php
session_start();
$_SESSION['VAR'] = $_POST['form_field_name'];
?>
http://www.google.com/search?q=php+session+tutorial
http://www.amazon.com/PHP-MySQL-Dynamic-Web-Sites/dp/032152599X
Good Luck
ryokale
12-20-2008, 09:13 PM
session_start();
if(isset($_POST['submit'])) {
$id = intval($_POST['productid']);
$amount = $_POST['amount'];
$_SESSION['products'][$id] += $amount;
}
This is how I did it in my school work I just returned. The products array is quite simple and not the best you could have.
Remember to put session_start(); in the beginning of every php file where you use session variables in.
Then if you want to iterate through the products in the array, use this one:
foreach($_SESSION['products'] as $productid => $amount)
doSomething();
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.