首页 > 解决方案 > 登录尝试失败时的模式弹出窗口

问题描述

问题:

我有一个登录表单,它在登录前检查 3 个条件,如果通过正确,如果正确是用户启用或验证,我想要做的是在用户未验证时弹出一个联系我们模式然而。

action.php 的标头

header('location: control-panel.php');
    }else{
        header('location: index.php?inactive=');
    }
    }else{
        header('location: index.php?dis');
    }
    }else{
        session_start();
        $_SESSION['isactive'] = false;
        header('location: index.php?err=1');
    }   
mysqli_close($mysqli);

从表格页面

<?php
$error = 0;

if (isset($_REQUEST['err'])){  
    $error = $_REQUEST['err'];
}
$dis = echo '<script>
$(window).on('load',function(){
if (!sessionStorage.getItem('shown-modal')){
    $('#myModal').modal('show');
    sessionStorage.setItem('shown-modal', 'true');
}
});
</script> ;

$inactive = 'Sorry Your Account Has Not Been Activated Yet<br /> Check Your Mail And Click On The Activation Link To Activate Your Account';

?>

试图:

$dis = echo '<script>
$(window).on('load',function(){
    if (!sessionStorage.getItem('shown-modal')){
        $('#myModal').modal('show');
        sessionStorage.setItem('shown-modal', 'true');
    }
});
</script> ;

标签: javascriptphp

解决方案


它可能与"and的用法有关'

尝试 1

echo "<script>
    $(window).on('load',function(){
      if (!sessionStorage.getItem('shown-modal')){
        $('#myModal').modal('show');
        sessionStorage.setItem('shown-modal', 'true');
      }
    });
  </script>";

输出 1

<script>
  $(window).on('load',function(){
    if (!sessionStorage.getItem('shown-modal')){
      $('#myModal').modal('show');
      sessionStorage.setItem('shown-modal', 'true');
    }
  });
</script>

尝试 2

echo '<script>
      $(window).on("load",function(){
        if (!sessionStorage.getItem("shown-modal")){
          $("#myModal").modal("show");
          sessionStorage.setItem("shown-modal", "true");
        }
      });
</script>';

输出 2

<script>
  $(window).on("load",function(){
    if (!sessionStorage.getItem("shown-modal")){
      $("#myModal").modal("show");
      sessionStorage.setItem("shown-modal", "true");
    }
  });
</script>

推荐阅读