doujiena0025 2017-02-11 20:21
浏览 38

即使选择了一个选项,html选择标记也需要说明

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>";   
  } 
}
?>
  • 写回答

1条回答 默认 最新

  • duanpei4455 2017-02-11 20:25
    关注

    Although it should not make a difference, but you should note that you repeated:

    required="true"
    

    If you can show the HTML code generated from PHP, it may help solving the issue.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作