Some of the offensive issues that websites often encounter are defensive

Source: Internet
Author: User
Tags basic sql injection

First, the most basic SQL injection

Prevent SQL injection functions

Use this function to filter the data submitted to the server side
function Data_filter ($data) {
if (GET_MAGIC_QUOTES_GPC ()) {
return $data = Stripslashes ($data);
}else{
return $data = mysql_real_escape_string ($data);
}
}


Second, a form of their own platform submitted to the library, others can know you this address, he himself in another server to write a form script to the address of the For loop constantly submitted, this address if not to protect, it will cause the database crashes, so we have to think of a way, as follows:

/*
* PHP prevents data from being submitted outside the station to prevent someone from writing a cyclic attack database
* Domain name consistency judgment
*/
function Checkurl () {
$servername =$_server[' server_name ']; Current Server domain name
$sub _from=$_server["Http_referer"]; Server domain name of previous page
$sub _len=strlen ($servername);
$checkfrom =substr ($sub _from,7, $sub _len);
if ($checkfrom! = $servername) Die ("Kid, are you going to get my database through this way?") Think of other ways. F u c k!  "); Checksum consistency can be
}

Third, through the browser, submitted the form, the database operation was successful, but he returned through the browser, return to the previous page, and another time to submit data, this will cause a message multiple filling, how to avoid, is simple as follows:

Window.history.forward (1); Added to JS inside, he will not go back,,, can't go back,,, we have become the past can not go back to ...

Some of the offensive issues that websites often encounter are defensive

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.