Answer the question
In order to leave comments, you need to log in
Do I need to process data from GET requests somehow?
I'm currently learning PHP and doing a study project. And so I thought about whether it is necessary to somehow process the data that I receive from the user in the form of a GET request?
A banal example: if in a GET request the user enters other data instead of the numerical value "?id=", can this lead to an XSS attack? Do I need to check this data? And if so, how?
Answer the question
In order to leave comments, you need to log in
There is no need to process this data in advance.
It is necessary at the place of application of these data to simply apply them correctly. And depending on this application - in different ways.
do I need to somehow process the data that I receive from the user in the form of a GET request
trim(stripslashes(htmlspecialchars( $yourVarible )));
Whether you need to do something with the input data depends on what you do with it next.
Are you inserting a SQL query string directly into the assembly? (DO NOT do this!)
Are you showing the user in the body of the page? (Need to filter)
There are ready-made functions for validating and filtering input data:
filter_input()
For example:
$query = filter_input(
INPUT_GET,
'q',
FILTER_SANITIZE_STRING,
FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH | FILTER_FLAG_STRIP_BACKTICK
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question