如何防止我的代码和 sql 架构从 sql 注入..??
我正在使用 PHP 进行编码..
我有一些登录表格。我读了一些 sql 注入查询
string sql = "SELECT * FROM table_name WHERE smth='" + UserInput + "'";
ExecuteSql(sql);
SELECT fieldlist
FROM table
WHERE field = 'steve@unixwiz.net'';
我知道发生 sql 注入是因为我们的编码错误和从数据库中检索数据的查询错误.. 我做了一些谷歌来保护我的项目免受 sql 注入器的影响,但我没有得到一些正确的信息..
我也使用 cakephp 框架进行编码,并且我知道在 cakephp sql 注入中非常困难,因为它会清理查询.. 是真的吗?
我得到了这个信息:-
CakePHP already protects you against SQL Injection if you use CakePHP's ORM methods (such as find() and save()) and proper array notation (ie. array('field' => $value)) instead of raw SQL. For sanitization against XSS its generally better to save raw HTML in database without modification and sanitize at the time of output/display.
有人会指导我吗?
谢谢 !!