Xss injection solution

Source: Internet
Author: User
Tags mysql injection

The htmlspecialchars () function in php will
 
The htmlspecialchars () function converts some predefined characters into HTML objects.
 
The predefined characters are:
 
& (And number) becomes & amp;
"(Double quotation marks) into & quot;
'(Single quotes) becomes & #039;
<(Less than) to become <;
> (Greater than) to become & gt;
Once <script> is changed to the & lt; script format, this js will not be executed.
Mysql injection prevention:
 
If (get_magic_quotes_gpc ()){
 
$ Name = stripslashes ($ name); // stripslashes () is used to clear the data obtained from the database or elsewhere. "\" Added by addshashes "\"
 
} Else {
 
$ Name = mysql_real_escape_string ($ name); // mysql_real_escape_string () mainly escapes 'and"
 
}
 
In addition, mysql cannot execute two statements in the same query. For example, mysql_query ('select * from table1; drop table B ;');
 
This is not acceptable.
 
From mountain's home

Related Article

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.