douqian5920 2011-04-11 20:04
浏览 6
已采纳

我是否需要在所有表单输入上使用mysql_real_escape_string?

I know I need to use them on user input fields such as a username entry field, but what about for radio buttons such as a gender option?

  • 写回答

8条回答 默认 最新

  • duanhun3273 2011-04-11 20:13
    关注

    Stop!

    You seem to be confusing escaping with data validation and data sanitization.

    You need to validate any data that comes in. Yes, this means making sure that radio buttons contain legal values.

    You need to sanitize any data that comes in. Should that text field contain HTML? No? strip_tags. Should that field be a number? Cast it as an integer.

    You need to escape any data that you place in the database. If you're still using the prehistoric "mysql" extension, this means using mysql_real_escape_string on everything as you build your query -- not before.

    You need to escape any data you echo to the user. htmlspecialchars is your friend.

    I've previously explained this in more detail, though this is not a duplicate question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度