如果已经登录,我如何阻止我的PHP页面进入登录页面? [英] How can I stop my PHP page from going to login page if it is already logged in?
本文介绍了如果已经登录,我如何阻止我的PHP页面进入登录页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,在facebook中,如果我们登录一次而没有注销,请单击浏览器中的后退按钮,它会再次重新加载主页。但是在我使用PHP制作的登录页面中,我按下浏览器中的后退按钮,尽管我已经登录,但我还是回到了登录页面。
我尝试过:
以下是登录页面的代码:
As an example, in facebook if we log in once and without logging out click on the back button in the browser it reloads the home page again. But in the login page which I made using PHP is I press the back button in the browser it takes me back to the login page in spite of the fact that I am already logged in.
What I have tried:
The below is the code for login page:
include 'left.php';
mysql_connect('localhost','root','');
mysql_select_db('onlineexam');
if(isset($_POST['submit']))
{
session_start();
$_SESSION['email'] = $_POST['email'];
$_SESSION['pass'] = $_POST['password'];
$email = $_SESSION['email'];
$query = mysql_query("select name,password,email from students where email = '$email'") or die("you are not registered");
$arr = mysql_fetch_assoc($query);
if ($arr['password']==$_SESSION['pass'])
{
$name = $arr['name'];
echo "<div class="righttop">
<h1>hello $name</h1><br>
<form method='post' action='index.php'>
<input type='submit' name='logout' value='LOGOUT'>
</form>
</br></div>";
}
else
{
echo "<div class="righttop">
<h1>Wrong Password. Try Again!!</h1>
<?php include 'righttop.php'; ???>
</div>";
session_destroy();
session_cache_expire();
}
}
elseif(isset($_SESSION['email']))
{
echo "halaluuya";
}
else
{
header("Location: http://localhost/project/index.php");
exit();
}
include 'rightbottom.php';
?>
推荐答案
_POST ['submit']))
{
session_start( );
_POST['submit'])) { session_start();
_SESSION ['email'] =
_SESSION['email'] =
_POST ['email'];
_POST['email'];
这篇关于如果已经登录,我如何阻止我的PHP页面进入登录页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文