Jump to content

$_POST Character replace


gvp16

Recommended Posts

Im bug fixing a script (not my own) and the use of  "  and  '  hasn't been filtered out before an insert query is ran.

 

there are about 4 scripts of 30 $_POST["something"] input elements that need to be checked, and i was wondering can i just do a find and replace on $_POST rather than each element?

 

Thanks.

Link to comment
Share on other sites

There might be some misunderstanding here. I thought you where actually looking to wrap calls to $_POST['something'] with some sanitising functionality within your code itself. eg; Search your code base and replace the calls.

 

You need to use the search and replace in your text editor or better still, a tool like sed if your on a *nix based system.

Link to comment
Share on other sites

I think were getting our wires crossed, im looking to avoid doing sanitation on over 90 separate $_POST[""] elements that have been used in a query.

 

rather than do

$name = str_replace(" ' ", """,$_POST["name"]);
$address= str_replace(" ' ", """,$_POST["address"]);
$town= str_replace(" ' ", """,$_POST["town"]);

and so on....

 

I was wondering if it was possible to do it on the $_POST array, so something like

 

foreach $_POST as $var{

    str_replace(" ' ", """,$var);

}

$name = $_POST["name"];
$address=$_POST["address"];
$town= $_POST["town"];

 

and then proceed to do the query

Link to comment
Share on other sites

i dont really, but i thought it would be better than removing the punctuation all together, i thought about using addslashes, but again i would have to add it to far to many elements, and then use stripslashes to display data correctly.

 

I will take a look into what you recommended, thanks for you help.

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.