提交后返回上一页,弹出模型

时间:2018-03-06 06:54:36

标签: javascript php jquery

我遇到的问题是我保存并返回index.php。模型弹出不起作用,保存后如何制作,返回index.php后会得到pup模型。希望所有亲可以帮我解决这个问题,tq。 这个是index.php //这部分是我的模型//

<form method="post" action="action.php">
<input type="text" name="username"/>
</form>
      <div class="modal fade" id="loginModal" role="dialog">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal">&times;</button>
              <div class="modal-title" style="padding-left: 18%;">
                <img style="width: 14%;" src="include/img/activation_page/logo.png">
                <img style="position: absolute; font-size: 20px;font-weight: 700; top: 15%; left: 30%;" src="include/img/memodise.png">
                <font style="font-size: 26px; font-weight: 300; position: absolute; top: 30%; left: 30%;">Log in</font>
                <font style="font-size: 12px; font-weight: 300; position: absolute; top: 60%; left: 30%;">Not a member? <span class="register1" id="register1">Register</span></font>
              </div>
            </div>
          </div>
        </div>
      </div>

//这是我的action.php //

if(isset($_POST['login'])){
 //save data to database//

 echo "<script>window.location='index.php'</script>";
<script>$('#loginModal').modal('show')</script>
}

3 个答案:

答案 0 :(得分:0)

if(isset($_GET['return'])){

  echo "<script>$('#loginModal').modal('show')</script>";
}

使用上面的代码段来显示模型。

action.php

if(isset($_POST['login'])){
  //save data to database//

 echo "<script>window.location='index.php?return=1'</script>";
}

希望这有帮助

答案 1 :(得分:0)

将它放在index.php中

<script>$('#loginModal').modal('show')</script>

答案 2 :(得分:0)

将此代码放入action.php

<?php if(isset($_POST['login'])){ ?>
    <script>
        $('#loginModal').modal('show');
        $('#loginModal').on('hidden.bs.modal',function(){
            window.location = 'index.php';
        });
     </script>
<?php }?>