filter - filtering user input in php -


I'm thinking that combining trim (), strip_tags () and addslashes (), to filter values ​​of variables from $ Is enough for _GET and $ _POST

It depends on what type of verification you want to verify.

Here are some basic examples:

  • If the data is being used in MySQL queries, use mysql_real_escape_query () on data instead of addlashes () Be sure to do
  • If there are file paths in it, make sure to remove the "../" parts and block access to the sensitive filename.
  • If you are going to display data on a web page, be sure to use htmlspecialchars ().

But the most important verification is accepting only the values ​​that you are expecting, in other words: Allow only numeric values ​​while expecting numbers etc.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -