login.php
<?php
session_start();
error_reporting(0);
include("config.php");
if(isset($_POST['submit']))
{
$pass= $_POST['password'];
$email= $_POST['email'];
if($email=='' && $pass=='')
{
echo '<p id="red">Wrong Email or Password.</p>';
}
else
{
$query=mysqli_query($con, "select * from `user` where `password`='".$pass."' and `email`='".$email."' and status='1'");
$countRow=mysqli_num_rows($query);
$fetch=mysqli_fetch_array($query);
if($countRow > 0)
{
$_SESSION['user_idd']= $fetch['user_id'];
//$_SESSION['user_idd'];
header('location:index.php');
}
else
{
echo '<p id="red">Wrong Email or Password.</p>';
}
}
}
?>
<form method="POST" id="myforms" autocomplete="off" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type="text" name="email" value="" placeholder="Enter Your Email" class="form-control">
<input type="password" name="password" value="" placeholder="Enter Your Password" class="form-control">
<input type="submit" name="submit" value="Login" class="btn btn-success">
</form>
index.php
<?php
session_start();
error_reporting(0);
include("config.php");
if(!isset($_SESSION['user_idd']))
{
header("location:login.php");
}
echo "hiii";
?>
我创建了简单的登录名,正如您在我的login.php文件中看到的那样。现在,我想在成功后从login.php
重定向到index.php
页面,但是问题是当我单击“提交”按钮时,它没有在index.php
页面上重定向我,它显示了相同的页面,并且当我直接在网址中调用index.php
时,它将再次显示login.php
。我不知道我在哪里做错了?请帮助我。
谢谢