首页 > 解决方案 > Bootstrap 4.3.1 下拉登录表单成功重定向

问题描述

我正在构建一个用户可以通过 Bootstrap Dropdown 登录的网站,我确实让它工作,它会登录用户并使用登录会话刷新整个页面但是如果用户输入了错误的凭据,它不会保持打开状态并提醒他们。我通过将登录表单放在下拉列表中的 iframe 中解决了这个问题,但它不再启动会话 - 请问有什么想法吗?我尽量不含糊,所以这里是 iframe 中的代码和下面的实际 URL - 谢谢 :)

<div class="header_login_form_dropdown">Login</div>
  <form name="login" action="" method="post" class="form">
    <div class="form-group">
      <label class="login_form_dropdown" for="lopc_username">Email</label>
      <input type="email" class="form-control" id="lopc_username" placeholder="email@company.com" name="lopc_username">
    </div>
    <div class="form-group">
      <label class="login_form_dropdown" for="lopc_password">Password</label>
      <input type="password" class="form-control" id="lopc_password" name="lopc_password">
    </div>

      <a href="https://littleorangeprinting.co.uk/2021/forgot_password.php" target="_parent" style="font-size: 12px; margin-left: 3px;">Forgot password</a>
      
    <button type="submit" name="submit" class="btn btn-primary login_btn">LOGIN</button>
      
      <div style="padding:15px 0 15px 0;  border-top: 2px solid #eee; font-size: 14px; color: #696969">
      New customer?  <a href="https://littleorangeprinting.co.uk/2021/register.php" target="_parent">Register here</a>
      </div>
      
       
      <?php
      

      
if (isset($_POST['submit']))

{

include('../265451/92631043.php');

$lopc_username = mysqli_real_escape_string($conn,$_POST['lopc_username']);
$lopc_password = mysqli_real_escape_string($conn,(md5($_POST['lopc_password'])));
$lopc_last_login = date("Y-m-d H:i:s");

$query = "SELECT * FROM lopc_reg_users WHERE lopc_username = '$lopc_username' AND lopc_password = '$lopc_password' ";

$result = mysqli_query($conn,$query);

if(mysqli_num_rows($result) == 1) 

{
    
    $_SESSION['lopc_username'] = $_POST['lopc_username'];
    $lopc_username = $_SESSION['lopc_username'];
    
    $query2 = "UPDATE lopc_reg_users SET lopc_last_login = '$lopc_last_login' WHERE lopc_username = '$lopc_username' ";
        $result2 = mysqli_query($conn,$query2);

    //header("Location: ".$_SERVER['PHP_SELF']);
    ?>
      <script>
            window.parent.location.reload();
      </script>
      <?php
    exit;
}
    else
    {
        echo '<div class="login_error">Username or password does not exist.</div>';
    }
      
}
      ?>
      
  </form>

https://littleorangeprinting.co.uk/2021

登录:test@test.com 通过:testing4321

标签: authenticationdropdown

解决方案


推荐阅读