I know this is asked question however I have tried almost steps but its not working. I know there is a silly mistake somewhere need an experts eye. My code:
// if(isset($_POST["country"]))
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$country = $_POST["country"];
echo '<script language="javascript">';
echo "alert(' Officer Already Alloted..!!!');";///Tried getting alert once POST, but no message
echo '</script>';
}
//? $country = $_POST["country"] : $company=1;
?>
<form action="#" method="POST">
<select class="country" name="wcpbc-manual-country" id="country" >
<?
$list=mysqli_query($con,"select * from country where status!='False'");
while($row_list=mysqli_fetch_assoc($list)){
$display="+".$row_list['phonecode']."-".$row_list['name'];
$flag=$row_list['isosmall'];
?>
<!--<select class="country" name="wcpbc-manual-country" id="country">-->
<option value="<?$row_list['phonecode']?>" data-iconurl="https://ipdata.co/flags/<?php echo $flag; ?>.png" <?php if($country==$row_list['name']){echo "selected";} ?>><? echo $display;?></option>
<!--<option value="IN" data-iconurl="https://ipdata.co/flags/in.png">IN some text</option>-->
<?
}
?>
</select>
</form>
<script type="text/javascript">
$("#country").selectBoxIt();
</script>
Actually I am trying to get selected value on to dropdown, it seems POST is not working for assigning value to $country
variable
I tried:
1. if($_SERVER['REQUEST_METHOD'] == "POST")
2. used form action="<?php echo $_SERVER['PHP_SELF']; ?>"
Please help.Thanks