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