[英]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.