简体   繁体   中英

How to prevent user edit form elements name by browser console

I have a form almost all form elements are generated by clicking a button dynamically, for example

<input type="file" id="upload_1_1" name="upload_1_1">

the form elements's name is useful to my webapps which represent the position (eg row = 1, col = 2), and it will be saved to DB later.

I found that, if the user change the name to "upload_2_1", they can still submit the form, and the $_POST will contains "upload_2_1". I use laravel 5.2, are there any ways to protect the form elements from being edit in browser console?

(the only way is check the sequence of the name in backend program?)

You cannot do it on front end level. Rather you can place a check on server side, for example: if(isset($_POST['upload_1_1])); Sof if you have dynamic names, then you could somehow dynamically check them as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM