Hello!
Suppose there is a page on which a list of users is displayed, and in front of each user there is a button “add as friend” or “block”. It is logical to track for which user the button was pressed, it can be placed together with an input field of the hidden type with a value equal to the user id in the database.
<form method="post"> <input name="user_id" type="hidden" value="22"> <input name="add_friend" type="submit" value="Добавить в друзья"> </form> Actually the following question torments me in this type of implementation: in the debugger you can see all the hidden fields and their values and nothing prevents the user from inserting the hidden-input value in not 22, say, 100, and thus the server will actually get the value user_id = 100 rather than 22, opposite which the button was pressed. It turns out that the user can thus add to the friends of someone who did not even send him a request.
It is clear that there should be checks on whether the request was really sent, etc. but is it still possible to somehow avoid or prevent the substitution of values in the hidden field, or is there a better solution for implementing such a mechanism?
Thank you in advance for your response!