Preventable inspect element? Or something else? (php and html) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Preventable inspect element? Or something else? (php and html)

I'm creating a test website in php and would like the input fields to be numbers only as it's going to use mathematical operators on the given values. Since my php code has to use mathematical operators, I get an error when submitting something else than numbers (or nothing at all), this can I prevent by setting the input type to number and required. Problem is when inspecting element, you can easily change that and still get the errors. Any way to prevent this? I can't remember how or if I can prevent errors from popping up on the user's side. (Sorry if not correct use of lingo as English is not my first language)

14th Jul 2019, 8:45 PM
MarkusS
MarkusS - avatar
5 Answers
0
theres no way to prevent user to open the developer options, but there's a way to detect them ( https://stackoverflow.com/questions/7798748/find-out-whether-chrome-console-is-open ) not sure it work across browsers. other than that, beside using developer option to change the input type. its still entirely possible to send the request to your server without the form you're provided. thats why also do validation in serverside.
14th Jul 2019, 8:51 PM
Taste
Taste - avatar
0
Sadly, everything that will be done on the site happens on the user's side. There is no sending data to the server side.
14th Jul 2019, 9:09 PM
MarkusS
MarkusS - avatar
0
Taste Forgot that I can mention someone in a comment
14th Jul 2019, 9:32 PM
MarkusS
MarkusS - avatar
0
how about this. create an onchange listener to your elements, with the input validation inside.
14th Jul 2019, 9:38 PM
Taste
Taste - avatar
0
Taste That could work, thanks
14th Jul 2019, 9:42 PM
MarkusS
MarkusS - avatar