Jump to content

[SOLVED] Clean User Input Using Foreach


matlyn

Recommended Posts

I am currently passing data from a form to a .php script for processing.  First item is to clean user input with statements like:

 

$cleanFname = trim($_POST[fname]);

$cleanFname = strip_tags($cleanFname);

$cleanLname = trim($_POST[lname]);

$cleanLname = strip_tags($cleanLname);

etc...

 

times however many variables are in the form.  A few varables are ok but for a form with many variables this could get to be a long list.

 

Can this process be done combining foreach() with the $_POST array so that I can cover all passed variables with just a couple of lines of code vs a long repetitive list?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/39953-solved-clean-user-input-using-foreach/
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.