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条)

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥15 如何修改pca中的feature函数
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况