i got a drop down in my html form, even if i have selected an option from it it still says i should select an item in the list and when i remove the required attribute and submit, it does not enter the option i selected into the database.
here is my code
<form style="margin-bottom: 5%;" method="POST" action="generate-invoive-results-service.php">
<?php
$query="SELECT diagnosis FROM medications WHERE diagnosis LIKE '%" . $_COOKIE['searchdisease'] . "%'";
$result= $con->query($query);
?>
<select required="true" id="nol" style="width: 40%; margin-left: -1%;" name="tdisease" data-toggle="tooltip" data-original-title="medications" class="date-picker form-control col-md-7 col-xs-12" data-rel="chosen">
<option value="">Select Disease</option>
<?php while ($row=$result->fetch_array(MYSQLI_ASSOC)) { ?>
<option value="<?php echo $row['ICD10']?>"><?php echo $row['diagnosis'];?> </option>
<?php } ?>
</select><br>
<input class="btn btn-warning" style="width: 170px; margin-left: -7%; margin-top: -1%; margin-bottom: 1%; color: #000;" type="submit" name="insertData" value="Create Invoice">
</form>
<?php
if(isset($_POST['insertData']))
{
$pred =$_POST['pre'];
$np =$_POST['nap'];
$sd10 =$_POST['tdisease'];
$pr =$_POST['pric'];
$ivd =$_POST['invd'];
$id =$_POST['user'];
$insert_user="INSERT INTO invoices(id, icd10, nappi_code, prescription, price, invoice_date, pid) VALUES ('','$sd10', '$np' ,'$pred','$pr','$ivd','$id')";
if(mysqli_query($con,$insert_user))
{
echo"<script>alert(' Invoice Details successfuly added to database')</script>";
echo '<meta content="1;generate-invoive-results-service-add.php?id='.$id.'" http-equiv="refresh" />';// redirects user view page after 3
}else{
echo"<script>alert('Unknown error occured')</script>";
}
}
?>