Php login problems

Source: Internet
Author: User
I want to log on to the & nbsp; page2.php page, so I want to log on to login. php & nbsp; go to the page3.php page and log on to login. php, how can I automatically jump to & nbsp; page1 and page2 after login, that is, I only use one login. p php login problems
I am now

To access the page2.php page, log on to the login. php page.

Go to the page3.php page and log on to login. php. how can I automatically jump to page1 and page2 after login?


That is to say, I only use one login. php. how can I jump to the desired page?

Login code:


Session_start ();

$ Username = $ _ POST ['username'];
$ Password = md5 ($ _ POST ['password']);

If (empty ($ username) | empty ($ password )){
Die ("user name or password is not filled! ");
} 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 page:

Session_start ();

If (empty ($ _ SESSION ["adminname"])
Echo "script" alert ('Please log on and perform the operation again! '); History. go (-1); script ";


?>


------ Solution --------------------
I don't know what you want to ask. didn't you write it out there? you can use headers and js to jump.
------ Solution --------------------
I am here to learn, and I also need this function.
------ Solution --------------------
The main idea is how to jump to the previous page after login, right? use the $ _ SERVER ['http _ referer'] function to get the address of the previous page, then you can jump to this page.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.