Simple SQL Injection Attack protection database processing code example

Source: Internet
Author: User

SQL injection is to set SQL traps in input parameters, which can lead to malicious database operations and attack the database.
Verify the input parameters to prevent entering keywords and symbols that may lead to database operations. This is a way to prevent SQL injection.


 

// Prevent SQL Injection parameter verification function checkSql (value) {var reg =/select | update | delete | insert | alter | drop | exec | count | '| "| = |; | >|<|%/I; if (reg. test (value) {alert ("do not enter special characters and SQL keywords in parameters! "); Return false ;}


This is just an example of a simple verification method. It is not enough to pass the parameter to the backend. Verification is also required. In order to prevent attacks that directly initiate requests across the client. The backend verification method is similar to this method.

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.