The ultimate clean/secure function

后端 未结 7 2254
忘掉有多难
忘掉有多难 2020-11-22 03:11

I have a lot of user inputs from $_GET and $_POST... At the moment I always write mysql_real_escape_string($_GET[\'var\'])..

I

7条回答
  •  别跟我提以往
    2020-11-22 03:46

    There is no point in simply passing the input through all these functions. All these functions have different meanings. Data doesn't get "cleaner" by calling more escape-functions.

    If you want to store user input in MySQL you need to use only mysql_real_escape_string. It is then fully escaped to store safely in the database.

    EDIT

    Also note the problems that arise with using the other functions. If the client sends for instance a username to the server, and the username contains an ampersand (&), you don;t want to have called htmlentities before storing it in the database because then the username in the database will contain &.

提交回复
热议问题