thinkphp Preventing SQL injection

Source: Internet
Author: User

For Web applications, SQL injection is undoubtedly the primary security issue, and the bottom of the system has a lot of processing and corresponding prevention mechanism for the data security, for example:

$User = M ("User"); Instantiate the User object $user->find ($_get["id"]);

Even if the user enters some malicious ID parameters, the system automatically adds quotation marks to avoid malicious injection. In fact, thinkphp curd all data in the database will be escape_string processed.

The usual security risk is that your query condition uses a string parameter, and then some of these variables depend on the user input from the client, to effectively prevent SQL injection problems, we recommend:

Query conditions use arrays as much as possible, which is a more secure approach;

Turn on the data field type validation, you can cast the numeric data type;

Use automatic validation and auto-completion mechanisms for custom filtering of applications;

field type checking, automatic validation, and auto-completion mechanisms we have described in detail in the model section.

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