Get more from POST in php?

Discussion in 'PHP' started by figo2476, Nov 15, 2007.

  1. #1
    I have a form, with option tag. When it is submited. The selected option's value
    will be posted. What about I want to receive the value of id + title as well?
    How do I do it in php?

    
    <form>
     <select>
       <option id=1 value=2 title=3></option>
       <option id=2 value=3 title=4></option>
     </select>
    </form>
    
    PHP:
     
    figo2476, Nov 15, 2007 IP
  2. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #2
    this is the way to get the value of the Dropdown box

    
    <?php
    if($_POST){
    	$cmbSelect=$_REQUEST['cmbSelect'];
    	echo $cmbSelect;
    
    }
    
    ?>
    
    
    PHP:
    this is change in Html

    <form>
    
     <select name="cmbSelect">
       <option id=1 value=2 title=3></option>
       <option id=2 value=3 title=4></option>
     </select>
    
    </form>
    HTML:
    hope it's helpful for you
     
    salmanshafiq, Nov 15, 2007 IP
  3. xmcp123

    xmcp123 Peon

    Messages:
    876
    Likes Received:
    49
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Whenever you are wondering what a variable is in post, just have the page that is being posted to say
    print_r($_POST);
    That will output everything.
     
    xmcp123, Nov 15, 2007 IP
  4. salmanshafiq

    salmanshafiq Well-Known Member

    Messages:
    260
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    128
    #4
    $_POST it's used for whatever form is posted/submitted or not.
     
    salmanshafiq, Nov 15, 2007 IP
  5. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Why won't people try reading before trying to post a solution... all 3 above posts have shown him nothing new.

    These values are not submitted with the form, as they shouldn't (waste of bandwidth). You should have the corresponding data in a data store or at least hard coded in the script. But if you must, you can try JavaScript and assign the values to hidden inputs on submit but note that will be creating a JS dependency.
     
    krt, Nov 15, 2007 IP