SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Oct 2003
    Location
    San Diego, CA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting the input from your form.

    Hi!

    Wonder if anyone there can point me to a direction. In a dropdown selection list within a form, I am trying to pass the selected item to a "where" clause in a select statement, but I can't get the value from the dropdown selection list. I have try sending the select variable through the HTTP_POST_VARS['myselect'], but the variable is empty.

    In the <form> tag I use something like this:
    <option value="Phone" name="myselect">phone
    <option value="address" name="myselect">address
    .........

    and
    within the <?php> tag I have statement like:
    $myselect=HTTP_POST_VARS['myselect'];
    select fields.... from table where $myselect .....

    If I can get the variable value from the form, worse case I can hard code the select statement using a case loop. Thanks in advance.

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firstly it would be $HTTP_POST_VARS, not HTTP_POST_VARS, and secondly, if you're using PHP >= 4.1.0 then you should really use $_POST['myselect'] instead

  3. #3
    SitePoint Evangelist
    Join Date
    Apr 2003
    Location
    Chicago, USA
    Posts
    417
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <?php
    
    ...
    
    $sql = "SELECT * FROM table WHERE field = {$_POST['myselect']}";
    
    ...
    
    ?>


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
  •