Home  >  Article  >  Backend Development  >  php 登陆的有关问题

php 登陆的有关问题

WBOY
WBOYOriginal
2016-06-13 12:56:011005browse

php 登陆的问题
我现在

想进入 page2.php这个页面,需要登陆,于是跳转到login.php这个页面

   进入page3.php页面,同样登陆,跳转login.php,我如何在登陆之后自动跳转到    page1跟page2


也就是说我只用一个login.php,我如何跳转到想要的页面

login代码:


    session_start();

$username=$_POST['username'];
$password=md5($_POST['password']);
    
    if(empty($username)||empty($password)){
die("用户名或密码还未填写!");
}else{
require_once 'db.php';
$sql = "select * from userinfo where username='".$username."' and password='".$password."'";
$query= mysql_query($sql);
    $row=mysql_fetch_array($query);



if($row['username'] == "admin"){
$_SESSION['adminname'] == "admin";
    header("location:manage/index.php");

}elseif($row['username'] == "gcb"){
$_SESSION['adminname'] == "gcb";

echo "<script>window.location.href='javascript:history.go(-1)';</script>";
}

}

?>

page1页面:

session_start();

if(empty($_SESSION["adminname"]))                                        
echo "<script>alert('请登录后再进行执行操作!');history.go(-1);</script>";


?>


------解决方案--------------------
不知道你想问什么,你那里不是写出来了吗,用header和js跳转都可以。
------解决方案--------------------
我是来学习的,我也需要这个功能。
------解决方案--------------------
楼主意思是如何在登陆后跳转到登陆之前的页面对吧,那样用$_SERVER['HTTP_REFERER']这个函数获取上个页面的地址,然后再跳转到这个页面就可以了。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn