登录失败后的会话,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>";
}
}
}
答案 0 :(得分:0)
尝试 -
"<script>
window.location = "index.php";
</script>"
只需替换
header('location:index.php');