dopgl80062 2016-07-18 08:26
浏览 35
已采纳

在模态中插入查询

I would like to ask for some assistance when it comes to inserting details into mysql database if data are inside a modal. I have been trying to complete this sample project of mine hoping that I can use it as a portfolio in the future. Here's the modal code.

main.php

<div class="modal fade" id="registrationModalold" role="dialog">
  <div class="modal-dialog">
  <!-- Modal content-->
    <div class="modal-content">
      <!--<form action="functions/actions.php" method="POST">-->
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Enrollment Details</h4>
      </div>
      <div class="modal-body">
        <form method="post" action="functions/actions.php">
          <h4 class="modal-title">Personal Information</h4>
          <div class="row">
          <div class="col-lg-6 col-xs-6">
            <label for="usr">Name:</label>
            <select class="form-control" name="courses">
            <?php 
              include 'ini/db.php'; //connect to database
              $sql = "SELECT distinct student_name FROM tbl_students";
              $res = mysqli_query($conn,$sql);
              echo "<option>---SELECT STUDENT---</option>";

              while ($row = mysqli_fetch_array($res)){
                echo "<option value=Course".$row['student_name'].">" . $row['student_name'] . "</option>";
              }
            ?>
            </select>
          </div><!-- ./col -->
          <div class="col-lg-6 col-xs-6">
            <label for="usr">Addres:</label>
            <input type="text" class="form-control" id="fullname">
          </div><!-- ./col -->
        </div>
        <div class="row">
          <div class="col-lg-3 col-xs-6">
            <label for="usr">Contact:</label>
            <input type="text" class="form-control" id="fullname">
          </div><!-- ./col -->
          <div class="col-lg-3 col-xs-6">
            <label for="usr">BirthDate:</label>
            <input type="text" class="form-control" id="fullname">
          </div><!-- ./col -->
          <div class="col-lg-3 col-xs-6">
            <label for="usr">Birth Place:</label>
            <input type="text" class="form-control" id="fullname">
          </div><!-- ./col -->
          <div class="col-lg-3 col-xs-6">
            <label for="usr">Gender:</label>
            <select class="form-control">
              <option id="male">Male</option>
                <option id="female">Female</option>
            </select>
          </div><!-- ./col -->
        </div>
        </br></br>
        <h4 class="modal-title">Other Information</h4>
          <div class="row">
            <div class="col-lg-6 col-xs-6">
              <label for="usr">Course:</label>
                <select class="form-control" name="courses">
                <?php 
                  include 'ini/db.php'; //connect to database
                  $sql = "SELECT crs_id,crs_name FROM tbl_courses";
                  $res = mysqli_query($conn,$sql);
                  echo "<option>---SELECT COURSE---</option>";

                  while ($row = mysqli_fetch_array($res)){
                    echo "<option value=Course".$row['crs_id'].">" . $row['crs_name'] . "</option>";
                  }
                ?>
                </select>
              </div><!-- ./col -->
              <div class="col-lg-6 col-xs-6">
                <label for="usr">Major:&nbsp<font color="red" size="2"><i>optional</i></font></label>
                <input type="text" class="form-control" id="fullname">
              </div><!-- ./col -->
            </div>
            <div class="row">
              <div class="col-lg-3 col-xs-6">
                <label for="usr">Mother's Name:</label>
                <input type="text" class="form-control" id="fullname">
              </div><!-- ./col -->
              <div class="col-lg-3 col-xs-6">
                <label for="usr">Mother's Occupation:</label>
                <input type="text" class="form-control" id="fullname">
              </div><!-- ./col -->
              <div class="col-lg-3 col-xs-6">
                <label for="usr">Father's Name:</label>
                <input type="text" class="form-control" id="fullname">
              </div><!-- ./col -->
              <div class="col-lg-3 col-xs-6">
                <label for="usr">Father's Occupation:</label>
                <input type="text" class="form-control" id="fullname">
              </div><!-- ./col -->
            </div>
          </div>
        <div class="modal-footer">
          <button name="btnregister" action="functions/actions.php" type="button" class="btn btn-default">Save</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
         </div>
       </form>
     </div>
   </div>
 </div>
</div>

As you can see there's a button there a button which points to my actions.php which is inside another folder which is functions folder. But when I click that nothing happens.

Here's the action.php:

if (isset($_POST['btnregisters'])) {
    echo "ASASASASASASASASASASAS";
    die("asdsadsada");
}
  • 写回答

3条回答 默认 最新

  • drjk87189 2016-07-18 08:30
    关注

    As you can see there's a button there a button which points to my actions.php which is inside another folder which is functions folder. But when I click that nothing happens

    <button name="btnregister" action="functions/actions.php" type="button" class="btn btn-default">Save</button>
    

    You said type="button". The entire point of that is to make the button do nothing (so you can bind JavaScript event handlers to it).

    Take that out and let it be the default (type="submit") which would submit the form.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵