Results 1 to 4 of 4

Thread: Session with CheckBox && Select Option

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question Session with CheckBox && Select Option

    Please help me to store values from CheckBox and Select elements to Session variable. following is the code.

    PHP Code:
    <?php

    // check1.php

    session_start();
    if(isset(
    $_POST["major"], $_POST["minor"], $_POST["card"]))
    {
          
    $_SESSION["card"]=$_POST["card"];
          
    $_SESSION["major"]=$_POST["major"];
          
    $_SESSION["minor"]=$_POST["minor"];
    }

    ?>
    HTML Code:
    <html>
    <head>
    <head>
    <title>Check Box</title>
    </head>
    <body>
    <form name="f" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
    <select size="3" name="card">
    <option name="card">One Card</option>
    <option name="card">Two Cards</option>
    <option name="card">Three Cards</option>
    </select>
    <br><br>
    &nbsp;<input type="checkbox" name="major" value="Major">Major
    &nbsp;<input type="checkbox" name="minor" value="Minor">Minor
    <br><br>
    <input type="button" name="b" value="Click" onclick="Redirect()">
    </form>
    </body>
    
    <script language="javascript">
    
    function Redirect()
    {
          location.href="check2.php";
    }
    
    </script>
    
    </html>


    PHP Code:
    <?php

    // check2.php

    session_start();
    echo 
    $_SESSION["card"]."<br>";
    echo 
    $_SESSION["major"]."<br>";
    echo 
    $_SESSION["minor"]."<br>";

    ?>

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Session with CheckBox && Select Option

    I am not sure why I bother taking the time to reply to your threads if you are just going to post the same question 5 minutes later:

    http://www.vbforums.com/showthread.php?t=424941

    Read my replies in that thread.
    Last edited by john tindell; Sep 9th, 2006 at 10:47 AM. Reason: Post Reported
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2006
    Posts
    266

    Question Re: Session with CheckBox && Select Option

    I need to know how to recover values from select option and check option and store it in session variables. Previously I did not ask this question. So please try to help me.

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: Session with CheckBox && Select Option

    Code:
    <script language="javascript">
    
    function Redirect()
    {
          location.href="check2.php";
    }
    
    </script>
    Do not submit for data, you need to change
    Code:
    <input type="button" name="b" value="Click" onclick="Redirect()">
    to
    Code:
    <input type="submit" name="b" value="Click" >
    you also need to close the Form tag.

    Code:
    <?php
    
    // check1.php
    
    session_start();
    if(isset($_POST["major"], $_POST["minor"], $_POST["card"]))
    {
          $_SESSION["card"]=$_POST["card"];
          $_SESSION["major"]=$_POST["major"];
          $_SESSION["minor"]=$_POST["minor"];
    }
    
    ?>
    <html>
    	<head>
    		<title>Check Box</title>
    	</head>
    	<body>
    		<form name="f" method="POST" action="check1.php">
    			<select size="3" name="card">
    				<option name="card">One Card</option>
    				<option name="card">Two Cards</option>
    				<option name="card">Three Cards</option>
    			</select>
    			<input type="checkbox" name="major" value="Major">Major
    			<input type="checkbox" name="minor" value="Minor">Minor
    			<input type="submit" value="Submit"/>
    		</form>
    
    	</body>
    </html>

Posting Permissions

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



Click Here to Expand Forum to Full Width