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 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    assigning a dropdown menu value to a session variable

    hi there,
    can any one tell me how i can assign a drop down menu value to a session variable...thanx in advance..

    ahmed

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    PHP Code:
    <?php
    session_start
    ();
    if(isset(
    $_POST['selectname'])) {
      
    $_SESSION['variable']=$_POST['selectname'];
    }
    ?>
    <html>
    <body>
    <form action="" method="post">
    <select name="selectname">
    <option value="a">A</option>
    <option value="b">B</option>
    </select>
    </form>
    </body>
    </html>

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hello

    hello Gjay,
    thanx for the suggestion.but it is not working. the drop down value is not getting assigned to the session variable.....can u tell me wht i can do...


    thanx
    ahmed



    Quote Originally Posted by GJay
    PHP Code:
    <?php
    session_start
    ();
    if(isset(
    $_POST['selectname'])) {
      
    $_SESSION['variable']=$_POST['selectname'];
    }
    ?>
    <html>
    <body>
    <form action="" method="post">
    <select name="selectname">
    <option value="a">A</option>
    <option value="b">B</option>
    </select>
    </form>
    </body>
    </html>

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just to make sure, you are submitting your form, right?
    The session variable is set from the POST var. You need to submit the form to do that.

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hmm....not getting assigned...

    degsy...my form is submitting and still my drop down variable is not getting assigned...can u tell me wht i can do...abt it..

    thanx
    ahmed

    Quote Originally Posted by degsy
    Just to make sure, you are submitting your form, right?
    The session variable is set from the POST var. You need to submit the form to do that.

  • #6
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Post your example code


  •  

    Posting Permissions

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