Pay attention to database security issues by accident, as shown in the following-php Tutorial

Source: Internet
Author: User
Accidentally pay attention to database security issues. The following table id field is the primary key auto-increment. if you want to delete a data entry, the & quot; deletefromtestwhereid] problem is that it is not safe. & quot; deletefromtestwhereid] $ _ POST [id] 2 accidentally pays attention to database security issues, as shown below
The id field of a table is the primary key auto-increment.

If you want to delete a data entry

So

"Delete from test where id =". $ _ POST ['id']

Is it possible that this is not safe?

"Delete from test where id =". $ _ POST ['id']

$ _ POST ['id'] = 2 or 1 = 1

Will this happen, resulting in deletion of all

------ Solution --------------------
Yes, so quotation marks are generally added to the value type.
"Delete from test where id = '$ _ POST [id]'"
------ Solution --------------------
Possible. This is often referred to as anti-SQL injection. Escape special characters.
------ Solution --------------------
It is impossible to escape the characters after quotation marks.
------ Solution --------------------
Intval
------ Solution --------------------
Method 1: Set magic_quotes_gpc = Off in php. ini.

Method 2: $ str = stripcslashes ($ str)

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.