Recently, a small project has made me accessible to PHP programming, the simple login function is OK. But in the actual use of the time to find a problem: User A Send a link to the user B,b open page prompt landing, but the successful landing, but jumped to the home, not a sent link. For a better user experience, B should automatically jump to the pre-login link after successful landing. Check the PHP help manual and use the $_server global variable to implement this function.
$_server is a super global variable of PHP, the detailed explanation about the $_server variable can be consulted: http://www.php.net/manual/zh/reserved.variables.server.php
The implementation method is: In the prompt user login, at the same time, in the session or cookie record the URL of the request page, the login verification succeeds in jumping back to the URL.
checklogin.php
Copy CodeThe code is as follows:
Session_Start ();
if (!isset ($_session[' LOGIN_OK '))
{
echo "";
$_session[' userurl '] = $_server[' Request_uri '];
Echo ';
}
login.php
Copy CodeThe code is as follows:
Session_Start ();
The Account password verification code is omitted here, verify OK and execute the following code
if (Isset ($_session[' Userurl '))
{
There are pages to jump in the conversation
$url = $_session[' Userurl ');
}
Else
{
No page to jump to, then go to homepage
$url = "home.php";
}
0.5s after jump
echo " ";
http://www.bkjia.com/PHPjc/710600.html www.bkjia.com true http://www.bkjia.com/PHPjc/710600.html techarticle recently, a small project has made me accessible to PHP programming, the simple login function is OK. But in the actual use of the time to find a problem: User A Send a link to the user b,b open ...