Bootstrap模式不响应我的PHP提交表单

时间:2015-08-16 05:45:28

标签: php twitter-bootstrap-3 bootstrap-modal

它没有显示任何错误,当我单击“保存”按钮时它没有响应。我已经尝试了PHP插入代码在其他页面没有bootstrap它工作,我想知道为什么它不能在bootstrap模式中工作。

这是我的HTML代码:

        <div class="modal-content">
                <div class="modal-header">
                    <h4>Add Topic</h4>
                </div>

                <div class="modal-body">
                    <form method="POST" action="index.php" role="form">
                          <div class="form-group">
                            <label for="cCategory">Category</label>
                            <input type="text" class="form-control" id="cCategory" name="category" value="<?php if (!empty($categ)) { echo $categ; }  ?>">
                          </div>        

                        <div class="form-group">
                            <label for="cTitle">Title</label>
                            <input type="text" class="form-control" id="cTitle" name="topicTitle" value="<?php if (!empty($topicTitle)) { echo $topicTitle; }  ?>">
                          </div>

                          <div class="form-group">
                            <label for="cDesc">Description</label>
                            <textarea class="form-control custom-control" rows="3" style="resize:none" name="desc" value="<?php if (!empty($desc)) { echo $desc; }  ?>"> </textarea>
                          </div>

                          <div class="form-group">
                            <label for="cDesc">Created By</label>
                            <input type="text" class="form-control" id="cDesc" name="createdby" value="<?php if (!empty($created)) { echo $created; }  ?>">
                          </div>
                        </form> 
                </div>
                <div class="modal-footer">
                  <button type="submit" name="submit" class="btn btn-primary">Save changes</button>
                </div>

        </div>

这是我的PHP代码:

    if(!empty($desc) && !empty($categ) && !empty($topicTitle) && !empty($topicTitle) && !empty($created))   {

        if($insert = $db->query("
             INSERT INTO pncontent (category, title, description, createdby, dateadded)
             VALUES ('$categ', '$topicTitle', '$desc', '$created', NOW() )
            ")) {
                echo $db->affected_rows, " Topic Save!";
            }else {
                echo "Failed to Save";
            }

        }else {
            echo "<p>All Fields are required</p>";
                    $desc = $_POST['desc'];
                    $categ = $_POST['category'];
                    $topicTitle = $_POST['topicTitle'];
                    $created = $_POST['createdby'];
        }
    }

0 个答案:

没有答案