When to sanitize PHP & MySQL code before being stored in the database or when its being displayed?

前端 未结 5 1561
一向
一向 2021-01-06 10:29

Okay I was wondering when should I sanitize my code, when I add store it in the database or when I have it displayed on my web page or both?

I ask this question beca

5条回答
  •  佛祖请我去吃肉
    2021-01-06 10:40

    I think you would want to escape the input (to avoid SQL injections) and sanitize (to avoid scripting attacks) at the same time, as you're inserting into the database.
    This way, you only need to run the sanitizer once on insertion, rather than (potentially) millions of times on display.

提交回复
热议问题