PHP Login to jump to the pre-landing page implementation ideas and code _php tutorial

Source: Internet
Author: User
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 ...

  • 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.