. Advertisement .
..3..
. Advertisement .
..4..
Hello everyone. I have a problem with “do not access superglobal $_post array directly”. Below is the details:
Do not Access Superglobal $_POST Array Directly
Why does that matter? How can I fix this warning, please?
The cause:
I read your error that was added because superglobals frequently contain user input, which should never be accepted as true.
The solution:
I have many solution to this problem. You can make use of.
1.The hint implies that some sort of filtration should be performed. In case the superglobal value contains any poisonous material, filter it. Where I have, for instance:
Instead, I used:
2.I concur with the other respondents that it is typically (nearly always) required to clean up Your input. However, have a look at this code (it’s for a REST controller):
3. You use only:
filter_input(INPUT_METHOD_NAME, 'var_name')
instead of$_INPUT_METHOD_NAME['var_name']
filter_input_array(INPUT_METHOD_NAME)
instead of$_INPUT_METHOD_NAME
This the error:Instead of always:
You should the problem:
4.Above is a portion of my code that caused NetBeans to issue the warning:
I discovered a straightforward approach to filter this array after doing a lot of research and realizing there are a gazillion other ways to do it.
That is my suggestion. I hope it will help you to solve the error you get. Good luck!!!