"PHP" uses redirection to disguise the form processing page does not exist

Source: Internet
Author: User
Tags php redirect

PHP redirection, very simple, except to print out the redirected JavaScript code directly,

Using the original PHP redirect is this:

<?phpheader ("Location:url"); exit; >

As soon as this statement is read, it jumps to the specified redirect URL.

Of course, PHP, first of all, it should be clear that the header () function must be placed in the beginning of the PHP program, and can not have another header () function or Setcookie () is called, if it is with the page output, this statement must be placed in

Use redirection to disguise that the form processing page does not exist. Makes it not so easy for hackers to discover our form processing pages. Because the form processing page generally involves database operations. It is not allowed to be accessed by someone else entering the URL.

For example, the following page redict.php, in practice is present, but you do not enter the correct parameter a, or incorrect submission form open this page, then give you a 404, let you think this page does not exist at all. Generally no one is so easy to guess that the parameter of this page processing is a. So it's the effect of protecting the form processing page.

This protection code is very simple. The idea is simply to determine if there is a parameter to be processed, and if not, redirect to a page that is not in the directory at all:
<?phpif (Empty ($_request["a"])) {header ("location:error.php"); exit;} else{//here is only to set the normal encoding output "hehe" Just! Header ("content-type:text/html; Charset=utf-8 "); echo "hehe";}? >



"PHP" uses redirection to disguise the form processing page does not exist

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.