PHP anti-injection, form commit value escape implementation _php Tutorial

Source: Internet
Author: User
In the development, we should pay attention to prevent SQL injection, so in the form submitted to the value to do the corresponding processing, before the data can be updated to the database
PHP annihilation function. Any value can be passed over to convert
Copy CodeThe code is as follows:
function quotes ($content)
{
If Magic_quotes_gpc=off, then start processing
if (!GET_MAGIC_QUOTES_GPC ()) {
Determine if the $content is an array
if (Is_array ($content)) {
If $content is an array, then it is processed by every single
foreach ($content as $key = = $value) {
$content [$key] = addslashes ($value);
}
} else {
If $content is not an array, it is processed only once
Addslashes ($content);
}
} else {
If magic_quotes_gpc=on, then do not deal with
}
Back to $content
return $content;

Use Stripslashes () to remove the backslash when displayed
Stripslashes (), it can be addslashes () processing automatically added to the (backslash) \ Remove

http://www.bkjia.com/PHPjc/327587.html www.bkjia.com true http://www.bkjia.com/PHPjc/327587.html techarticle in the development, we should pay attention to prevent SQL injection, so in the form submitted to the value to do the corresponding processing, before the data can be updated to the database php annihilation function. Any value is ...

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