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 MATLAB图像问题
  • ¥20 树莓派5做人脸情感识别与反馈系统
  • ¥15 selenium 控制 chrome-for-testing 在 Linux 环境下报错 SessionNotCreatedException
  • ¥15 使用pyodbc操作SQL数据库
  • ¥15 MATLAB实现下列
  • ¥30 mininet可视化打不开.mn文件
  • ¥50 C# 全屏打开Edge浏览器
  • ¥80 WEBPACK性能优化
  • ¥30 python拟合回归分析
  • ¥500 metaswitch 6010