I. Several methods to prevent Injection
In fact, it turns out that we need to filter out some common keywords and conformances such:
Select, insert, update, delete, And, *, etc.
Example:
Function inject_check ($ SQL _str ){
Return eregi ('select | insert | update | Delete | \ '| \/\ * | \ .. \/| \. \/| Union | into | load_file
| OUTFILE ', $ SQL _str); // Filter
}
Or filter special characters between system functions.
Addslashes (content to be filtered)
2. PHP security settings in other places
1. Set register_globals = off to disabled.
2. Do not omit small quotation marks or single quotation marks when writing SQL statements.
Select * from table where id = 2 (not standard)
Select * From · Table · where · ID · = '2' (standard)
3. Use accepted parameters such as $ _ post $ _ get $ _ Session correctly and filter them.
4. Improve database naming skills. You can name important fields according to program characteristics.
5. encapsulate common methods to avoid direct exposure of SQL statements