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)