PHP保护GET参数

ben*_*e89 8 php security get

好的,请考虑这个网址:

example.com/single.php?id=21424
Run Code Online (Sandbox Code Playgroud)

对你和我来说很明显,PHP将获取id并通过mysql查询运行它来检索1条记录以在页面上显示它.

反正有一些恶意黑客会弄乱这个url并对我的应用程序/ mysql数据库构成安全威胁吗?

谢谢

Int*_*idd 10

当然,永远不要将用户条目(_GET,_POST,_COOKIE等)视为安全.

使用mysql_real_escape_string php函数来清理变量:http://php.net/manual/en/function.mysql-real-escape-string.php

关于SQL注入:http://en.wikipedia.org/wiki/SQL_injection