javascript - When registering, the same user registers multiple times, and multiple pieces of the same data appear in the database. The background has been verified, and the front-end js also limits submission once every two seconds, but multiple pieces of data still appear.
世界只因有你
世界只因有你 2017-06-30 09:52:16
0
8
960

When registering, the same user registers multiple times, and multiple pieces of the same data appear in the database. The background has been verified, and the front-end js also limits submission once every two seconds, but multiple pieces of data still appear

世界只因有你
世界只因有你

reply all(8)
習慣沉默

The front-end can set the registration button to be clickable when entering the page. When clicking to send a registration request, the registration button is first set to be non-clickable. When the request comes back and the registration fails, the button is set to be clickable.

伊谢尔伦

Use unique index as a restriction in the database

淡淡烟草味

I don’t know whether you use debouce or throttle to limit submission to two seconds

A better approach is to click Register to disable the button, wait for the request to return, and then enable the button in the callback function. Remember to enable the Register button in the callback that reports an error

Backend database fields must also be uniquely indexed

Peter_Zhu

Server-side verification requires uniqueness judgment; disable clicks after clicking on the front-end button, wait for the server to return and unblock clicks, or implement it through timeout

学习ing

Registration requires unique verification

给我你的怀抱

Database plus username primary key unique verification

三叔

Although the solution of disabling buttons on the front end is also necessary, it only prevents ordinary users from clicking multiple times and cannot prevent non-browser 'users'
No matter how many repeated requests the server accepts, it must be processed by the backend
Purpose The same user can only register once, refer to other answers, primary key

世界只因有你

Refer to my article How to prevent clients from sending repeated requests in web projects

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template