Advanced Search

Results 1 to 8 of 8

Thread: How to submit html form info to sessions

  1. #1
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default How to submit html form info to sessions

    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!

  2. #2
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    39 views, no replies...

  3. #3
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Try posting the code you have so far.
    Eddy Proca
    I love Dropbox. Get it through my girlfriend's referral link (I reached my limit) and both you and her get 500 MB extra! Thanks and you're welcome!

  4. #4
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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:



    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.



    Code:
    <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;">
    					&nbsp;&nbsp;&nbsp;&nbsp;<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>
    					&nbsp;&nbsp;&nbsp;&nbsp;<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>
    					&nbsp;&nbsp;&nbsp;&nbsp;<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>
    					&nbsp;&nbsp;&nbsp;&nbsp;<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.



    Code:
    <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;">
    					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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.



    Code:
    <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!

  5. #5
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Getting started would help, like how to make a session....

  6. #6
    Join Date
    Feb 2006
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Still looking for assistance

  7. #7
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Code:
    <?php
    
    session_start();
    
    $_SESSION['VAR'] = $_POST['form_field_name'];
    
    ?>
    http://www.google.com/search?q=php+session+tutorial

    http://www.amazon.com/PHP-MySQL-Dyna.../dp/032152599X

    Good Luck

  8. #8
    Join Date
    Dec 2008
    Location
    Helsinki, Finland
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
     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:
    Code:
     foreach($_SESSION['products'] as $productid => $amount)
    doSomething();

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •