简体   繁体   English

登录失败后,在login.php中进行会话检查,而不是将其重定向到首页(index.php)

[英]Session after login unsuccess and in login.php check for it, not redirect it to homepage (index.php)

Session after login unsuccess and in login.php not redirect it to homepage ( index.php ). 登录失败后以及在login.php中的login.php不会将其重定向到首页( index.php )。 example link ( pos.beckie168.com ). 示例链接( pos.beckie168.com )。

please help me 请帮我

username : tepbopea
password : 8886188

Code Login.php: 代码Login.php:

<?php
    session_start();
    require 'dbconfig/db.php';
    $a='Username';
    $b='password';
    if(isset($_POST['btnsend'])){
        $name=$_POST['txtusername'];
        $pwd= $_POST['txtpwd'];
        if(trim($name)==''){
            $a="Name required";
            }elseif(trim($pwd)==''){
                $b="Password required";
                }else{
                    $sql="select * from tbluser where username='$name' and password='$pwd'";
                    $query=mysqli_query($con,$sql);
                    $num= mysqli_num_rows($query);
                    if($num>0){
                        $_SESSION['userlogin']=$name;
                        header('location:index.php');
                        }else{

                            echo"<span style='color:red;margin-left:40%;margin-top:20px;font-family:Segoe,sans-serif;'>
                            Wrong Username or  Password</span>";
                            }
                    }
        }

To Try- 尝试-

"<script>
        window.location = "index.php";
 </script>"

Just replace 只需更换

 header('location:index.php');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM