dqqpf32897 2015-12-08 21:31
浏览 29
已采纳

使用模式表单更新SQL

I am making a Modal Form that pops up on Click of a button and opens up a input field. On Save it pushes the values to webpage URL that it is poping up from. I am trying to capture that value and update on the database. Which is happening perfectly fine. But I want to refresh the page as the URL still holds the value for from the Modal form.

<div id="custom-modal" class="modal-demo">
        <button type="button" class="close" onclick="Custombox.close()"><span>&times;</span><span class="sr-only">Close</span></button>
            <h4 class="custom-modal-title">Add New Category</h4>
                <div class="custom-modal-text text-left">
                    <form role="form">
                        <div class="form-group" method="post">
                            <label for="name">Category Name</label>
                                <input type="text" class="form-control" id="cat_name" name="cat_name" placeholder="Enter category name">
                        </div>
                        <button type="submit" class="btn btn-default waves-effect waves-light" name="btn-savecat" id="btn-savecat">Save</button>
                        <button type="button" class="btn btn-danger waves-effect waves-light m-l-10">Cancel</button>
                        <?php
                        if(isset($_GET['cat_name']))
                                    {   
                                        try
                                            {
                                                    $id=$_GET['cat_name'];
                                                    $result = $DB_con->prepare("INSERT INTO category(cat_name,cat_status) 
                                                    VALUES(:userid,'Active')");
                                                    $result->bindParam(':userid', $id);
                                                    $result->execute();


                                            }
                                        catch(PDOException $e)
                                            {
                                                echo $e->getMessage();
                                            }                                           
                                    }   
                        ?>

                    </form>
        </div>
  • 写回答

1条回答 默认 最新

  • doubi7496 2015-12-08 22:02
    关注

    I think you should be able to do it with new HTML5. There is an option for rewriting url without reloading the page. You cannot however change the domain name for security reasons. Look up history api. I think it would be something like the following:

    history.replaceState("object or string", "title", "/another-new-url");
    

    Check this one out.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)