-1

I'm having some trouble here when I try to get the value from my using

I'm doing this in a dinamic way because the number of values which are shown can be different.

After submiting ($_POST) I'm getting "Undefined index: country" when I use $query = "SELECT id FROM country WHERE country.name = '" . $_POST['country'] . "'";

I already checked $_POST with var_dump() and this is the only value that is not being sent. What should I do?

Here is the code, thanks in advance.

<select required="">
     <?php for ($x = 0; $x < $count; $x++) { ?>
        <option name="country" value="<?php echo $country_name[$x]->name ?>">
            <?php echo $country_name[$x]->name ?>
         </option>               
      <?php} ?>
 </select>

1 Answers1

1

Change to

<select name="country">
     <?php for ($x = 0; $x < $count; $x++) { ?>
        <option  value="<?php echo $country_name[$x]->name ?>">
            <?php echo $country_name[$x]->name ?>
         </option>               
      <?php} ?>
 </select>
vitalik_74
  • 4,573
  • 2
  • 19
  • 27