java - How to implement username or email login in the same input box?
迷茫2017-05-17 10:02:39
0
3
713
As shown in the two pictures, the user table has username and email fields. When the page is logged in, how to implement the function of logging in with username or email? Looking for answers.
Dear, my idea is: if it is xxx@xxx.xxx, it is the email login, otherwise it is the username login. Correspondingly, if you log in by email, you call the method of querying and verifying the email; if you log in with a username, you call the method of querying and verifying the username. Above!
Dear, my idea is: if it is xxx@xxx.xxx, it is the email login, otherwise it is the username login.
Correspondingly, if you log in by email, you call the method of querying and verifying the email; if you log in with a username, you call the method of querying and verifying the username.
Above!
It can be easily processed and sent directly back to the backend, and the backend can match it in sequence.
select * from user where (username=xxxxx and password=yyyy) or (email=xxxxx and password=yyyy)
This is okay too