How to handle key and request value in php?

Asked

Viewed 40 times

1

I am willing to handle the $_REQUEST keys and values that a page receives.

The check would be:

if(!empty($_REQUEST)){
   // Tratamento das chaves e valores
}

This is because I had some problems regarding security, where key values were being changed :(

For this reason I need to do these treatments and I don’t know what is the most efficient way to do this.

To illustrate this, it follows a printing problem of a $_REQUEST:

Array
(
    ["onmouseover] => '4Puv(9698)'bad="
)
  • 3

    What is the problem with keys? related: How to validate each data type received from a form?

  • 1

    but what kind of treatment do you need? Or have more aver with validation? Before Oce played from the direct form on the bench?

  • So I believe that the htmlspecialchars function will solve this for me. The problem is that I would need to handle the keys of this request and not just the values.

  • Comes with keys with characters like # , . ^ ~ & % $? either remove them or what?

  • My problem is more with single quotes, double quotes that are coming in the values keys. I will put an example in the question.

  • But what’s wrong with quotation marks? Are you afraid of sql-Injection? If this is the case use preparedStatement, if the problem is also html-Injection then at the time of SELECT when you bring the data to while use the htmlespecialchars.

  • 1

    Already improved, one of the problems may be in setting in the form fields, sometimes as array ex: name="produtos[id][algo]"

Show 2 more comments
No answers

Browser other questions tagged

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