Is this a safe way to filter data and prevent SQL-injection and other attacks?

本小妞迷上赌 提交于 2019-12-06 00:03:06

You're using deprecated function as magic_quotes and ereg_*. To prevent Sql injection you should use prepared statement (I suggest to use PDO) and to prevent XSS you should use strip_tags() as you're doing.

Use parameters in your queries instead of concatenating string.

Filters and cleaners are usually not safe enough.

If you are using integer ids idFilter() can be safely stripped down to

function idfilter($idfilter) {
  return (int)$idfilter;
} 

As others have suggested, using parametrized queries is the right way to go though.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!