Jump to content

$_POST filter


drisate

Recommended Posts

Hey guys i am using a global filter on my $_POST

 

function filter($str){return htmlentities($str, ENT_QUOTES);}

$_POST = array_map('filter', $_POST);

 

It helps me encode the stuff into the database.

It works great on all my fields exept my arrays ...

 

Ex: fields like this <input type="text" name="name[]" size="20"> breaks

 

Any sugestions on gething this global filter working?

Link to comment
https://forums.phpfreaks.com/topic/221511-_post-filter/
Share on other sites

I would also suggest that you should not be using htmlentities on your data before storing it in the database. IMO, you should always maintain data in it's original state when storing it in the database (except for using something such as mysql_real_escape_string() to prevent injection attacks).

 

If you ever need to allow the user to modify the input you then need to try and revert the code back to it's original format which is not easy to do. I always try to store the original data and then determine what modifications, if any, need to be used during runtime based upon the context of where the data is being used.

Link to comment
https://forums.phpfreaks.com/topic/221511-_post-filter/#findComment-1146694
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.