How to receive all data for $ _POST, without being assigned by a variable? [duplicate]

-1

I have the following cycle that converts the data received for POST at once without assigning it to an Ejm variable:

////Envio $_POST['name']='valentina'

and with

if(@$_POST)
{
    foreach($_POST as $campo => $valor)
    {

        $asig = "$" . $campo . "='" . htmlspecialchars($valor,ENT_QUOTES) . "';";
        eval($asig);

    }
    echo $name  // $name = valentina
}

But for security reasons I want to remove the function eval() How can I replace the function eval() ? or what other method can I use to replace the foreach ?

    
asked by Fercho Jerez 25.08.2016 в 07:56
source

1 answer

0

In your case you can avoid the use of eval (which entails security risks) with variable variables .

Try with:

$$campo = htmlspecialchars($valor, ENT_QUOTES);
    
answered by 25.08.2016 в 08:45