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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.