0

i have one form in php, in this form have one select option

<select id="birdname" style="width: 150px; height: 25px; border-radius: 5px;">
    <option>--Cambiar vendedor --</option>
    <?php
    $selectagent = "SELECT * FROM `" . $prefix . "user`";
    $resultforagents = mysql_query($selectagent);
    while ($agent = mysql_fetch_object($resultforagents)) {
        ?>
        <option value="<?= $agent->user_id ?>" ><?= $agent->username ?></option> 
<?php } ?>                          
</select>
<div id="stage" style="display:none;"></div>

Showing name of username, i need insert selected username (reference not name) into sql

<?php
$userId = $_POST['birdname'];
$idtill = $_SESSION['caj'];
$cashid = $_SESSION['cash'];
$mvalue = number_format($givenamount, 2, '.', '');
$mdate = date("Y-m-d H:i:s");
$moption = '1';
$sql = "INSERT INTO `" . DB_PREFIX . "order_user`(`user_id`, `order_Id`, `till`, `value`, `operation`, `comment`, `date`,`cashid`) VALUES ('" . $userId . "','" . $lastorderidis . "','" . $cashid . "','" . $mvalue . "','" . $moption . "', '" . " " . "', '" . $mdate . "','" . $cashid . "')";
$common->showresultsql($sql, 'update', 1);

echo $lastorderidis;
?>

Thanks

Aditya
  • 1,241
  • 5
  • 19
  • 29
  • on your select use a name to obtain the value on the form action page – Marco Mura Dec 10 '14 at 09:51
  • possible duplicate of [get the selected index value of – Matheno Dec 10 '14 at 09:54

1 Answers1

1

Add the name tag to your select value to get the value of select like this:

<select id="birdname" name="birdname">

Now you will have the value by $_POST['birdname']

More info here: get the selected index value of <select> tag in php

Community
  • 1
  • 1
Matheno
  • 4,112
  • 6
  • 36
  • 53