In PHP when submitting strings to the database should I take care of illegal characters using htmlspecialchars() or use a regular expression?

前端 未结 6 1998
说谎
说谎 2020-11-22 03:18

I am working on a form with the possiblity for the user to use illegal/special characters in the string that is to be submitted to the database. I want to escape/negate thes

6条回答
  •  天涯浪人
    2020-11-22 03:57

    You haven't stated what these illegal characters may be but you should definitely be using the database API's supplied mechanism to escape data. For instance, if you're using MySQL, use PDO parameterized SQL statements.

提交回复
热议问题