PHP and mysqli . How to apply a filter without directly accessing the super global $_POST

Asked

Viewed 56 times

0

How to apply a filter without directly accessing the super global $_POST. changing that:

$F['email']  = mysqli_real_escape_string($conn,$_POST['email']);

That’s why:

$email = filter_input_array(FILTER_INPUT,'email',FILTER_SANITIZE_EMAIL);  
$F['email']  = mysqli_real_escape_string($conn,$email);

but it doesn’t work , which is the right syntax if it exists ??

  • You’ve tried it this way $email = filter_input_array(INPUT_POST, ['email' => FILTER_SANITIZE_EMAIL]);

  • Why don’t you want to access the super global? And instead of filters, in my opinion it’s worth it if you create your own regular expression to detect emails and, if applicable, sanitize them.

  • yes regular expression I use ,but in this case it is to get data that comes from the form.com mysqli, this way I wrote I use with Pdo , but for mysqli does not work understand.

1 answer

0

Just as well as right:

$email = filter_input(INPUT_POST,'email',FILTER_SANITIZE_EMAIL); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.