Jump to content

Post data + globals


Recommended Posts

why would it matter to use $_POST['name']? what are you trying to accomplish?

 

 

in the mean time, look into the define() function. i believe you'd be able to store your new variable names into an array... then zip through the names array and the $_POST array to affilliate a certain post variable with a new defined name.

Link to comment
https://forums.phpfreaks.com/topic/41354-post-data-globals/#findComment-200388
Share on other sites

Hi,

 

Maybe im not explaing my question well enough..

 

I am covered for sql injection ValidateInput($value);

 

The following code:

 

foreach($_POST as $key=>$value){
$_POST[$key] = ValidateInput($value);
}

 

cleans my post data then I use the variable as $_POST['name']

 

this code:

 

foreach($_POST as $key=>$value){
$$key = ValidateInput($value);
}

 

*note: $$key

 

cleans my post data then I can simply use the variable $name

 

This creates less typing and also shorter code.

 

Is this acceptable/safe way to code?

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/41354-post-data-globals/#findComment-200529
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.