search

Home  >  Q&A  >  body text

java - How to implement username or email login in the same input box?

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.

迷茫迷茫2780 days ago716

reply all(3)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-17 10:04:39

    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!

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-17 10:04:39

    It can be easily processed and sent directly back to the backend, and the backend can match it in sequence.

    reply
    0
  • 怪我咯

    怪我咯2017-05-17 10:04:39

    select * from user where (username=xxxxx and password=yyyy) or (email=xxxxx and password=yyyy)
    This is okay too

    reply
    0
  • Cancelreply