[英]Session after login unsuccess and in login.php check for it, not redirect it to homepage (index.php)
登录失败后以及在login.php
中的login.php
不会将其重定向到首页( index.php
)。 示例链接( pos.beckie168.com )。
请帮我
username : tepbopea
password : 8886188
代码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>";
}
}
}
尝试-
"<script>
window.location = "index.php";
</script>"
只需更换
header('location:index.php');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.