Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: session array

  1. #1
    New Coder
    Join Date
    Apr 2012
    Posts
    12
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post session array

    <form method="post" action="ecc.php">
    <table bgcolor="#FFCC00" width="40" border="2" cellspacing="10">
    <tr><td colspan="20"><input type="radio" name="type" value="1000" />1000 point </tr>
    <tr><td colspan="20"><input type="radio" name="type" value="500" />500 point </tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit" id="submit" />
    </table>
    </form>

    <?php

    session_start();
    if (isset($_POST['Submit'])) {
    $_SESSION['a'][0] = $_POST['type'];
    if($_SESSION['a'][0]== 1000)
    { $b==1000;}
    else
    { $b==500;}
    echo"the no is ".$b;

    }


    ?>
    please check it that it is right. I want to save the value of radio button in a variable so that I may use it in further calculation.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    associative offsets are case sensitive. There is also no guarantee that submit will be provided in IE as it doesn't conform to the w3 successful fields for forms.
    Use if (isset($_POST['type'])) as your comparison.


  •  

    Tags for this Thread

    Posting Permissions

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