-3

当我们在订阅网站时尝试输入用户名时,它会拒绝我们的选择并向我们显示一些我们可以选择的用户名。例如,如果我输入 Junaid,该站点会显示 Junaid1123、Junaid444 选项...我如何为我的站点执行此操作?

4

1 回答 1

1
1) Use javascript to get the entered username from the form.
2) Send a synchronous ajax request containing the entered username to a program on your server.
3) Have your server program check if the entered username is in your database.
3) If the entered username is not in your database, then create an array of 5 random numbers.
4) Create an array of 5 strings, where each string consists of the username added to each of the random numbers.
5) Check your db for the 5 usernames, and eliminate any that already exist.  Create more as necessary. 
6) Send back five usernames in the response.
7) Use js to display the five names to the user.
于 2013-06-09T07:04:41.973 回答