In php, header redirection uses include to solve the problem of parameter loss.

Source: Internet
Author: User

In php, header redirection uses include to solve the problem of parameter loss.

If you encounter problems in a project, when a user successfully logs on to the homepage with the header, it is always wrong and cannot jump to the page you want. It took a long time for du Niang to find a solution. I will share it with you here.

Some colleagues reported that some recently launched games cannot be loaded with style files due to overseas registration and need urgent repair.

The registration process goes through a single portal. The core judgment is checkip. You only need to make a game_id judgment in the template program without real-name authentication. Because I was too certain and eager to get off work, coupled with the stress of everyone's urging, I was suddenly blinded and made two mistakes: first, the location of game_id was determined in advance, as a result, many variables are not uploaded to the target page. Second, they do not understand the meaning of header jump and include, and directly use headers for redirect.

The page after the header jump cannot inherit the variables and other elements of the previous page. For example:

A. php file

?

1

2

3

4

5

6

7

$ UserEname = "crystal ";

$ UserCname = "Cheng ";

// Your code

................................

Header ("location: B. php ");

// Your code

..................

If $ userEname is referenced in the B. php file, what is the result? $ UserEname = null. If you use include to include B. php, you can avoid the problem of null $ userEname.

The above is all the content of this article. I hope you will like it.

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.