PHP Prevent Brush screen

Source: Internet
Author: User
before data processing and saving, first determine how the browser gets the page. Using $_server
["Request_method"] variable to get the browser to get the page way. Check to see if it is "POST". In the
A session is used in the script to record whether the user has passed the normal path (that is, the page that filled the submission) could be free
data. or use $_server["http_referer"] to detect, but this is not recommended. Because part of the Bangs
Referer is not set, some firewalls will also block referer. In addition, we also want to submit
Check to see if there is duplicate content in the database. Take the message book as an example, use the session to determine:
fill in the content of the page, we added at the front end:
$_session["Allowgbookpost"]=time ();//time when registration is completed
on the page where the message is received and saved we also use the session before we can process data
the following processing:
if (Strtoupper ($_server["Request_method"])! = "POST") {die ("error: Do not outside
submitted by the Ministry. "); } Check if the page Get method is post
if (!isset ($_session["Allowgbookpost"]) or
(Time ()-$_session["Allowgbookpost"] < 10)) {Die ("error: do not submit externally.
"); } Check the time when the message was filled out
if (isset ($_session["Gbookposttime"]) and
(Time ()-$_session["Gbookposttime"] < 120)) {Die ("error: two times to submit a message
not less than 2 minutes apart. "); } Check the message interval
unset ($_session["Allowgbookpost"]);//unregister allowgbookpost variable to prevent one-step
submit in the Fill page multiple times
$_session["Gbookposttime"]=time ();//Register the time to send messages to prevent flooding or malicious attacks
...
data processing and preservation
...

The above on the introduction of PHP to prevent brush screen, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

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