PHP after landing to jump to the landing page before the realization of ideas and code

Source: Internet
Author: User
Tags manual php programming

 php after landing to jump to the front page, the use of $_server global variables can achieve this function, the following has a good example, I hope to help you.

Recently hand a small project let me contact with PHP programming, simple landing function has been OK. But in actual use when found a problem: User A To send a link to the user B,b open page prompts landing, but after the successful landing, but jump to the home page, not a send link. In order to have a better user experience, B Landing after the successful should automatically jump to the link before landing. Check the PHP help manual and use $_server global variables to achieve this functionality.     $_server is a super global variable for PHP, the detailed explanation of $_server variable can be referenced as follows: http://www.php.net/manual/zh/ The reserved.variables.server.php    Implementation method is: When prompts the user to log in, in the session or the Cookie records the request page the URL, after the login authentication succeeds jumps back to this URL.   checklogin.php  code as follows: Session_Start ();    if (!isset ($_session[' LOGIN_OK '))   {  echo " <script Language=javascript>alert (' the page to be accessed needs to be logged in first. ');</script> ";  $_session[' userurl '] = $_server[' Request_uri '];  echo ' <script language= javascript>window.location.href= "login.php" </script> '; }    login.php  code is as follows: Session_ Start ();   //Here omit account password Verification code, verify OK and execute the following code     if (isset ($_session[' Userurl '))   { // There are pages to jump   $url = $_session[' Userurl ']; }  else //No page to jump, then go to home   $url = "{ ";  }&NBSP  //0.5s after jump   echo "<meta http-equiv=" Refresh "content=" 0.5;url= $url ">";   

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.