简体   繁体   中英

How to authenticate a username & password of the user without redirecting to another page?

I want to authenticate the user without refreshing/redirecting to another webpage. If the username and password combination is incorrect, I want to show a message there itself without redirecting/refreshing the page. And if the username and password combination is correct, then I want the page to redirect to home page. An example is given below, the error message appeared without refreshing the page. Can anyone help me in get this thing done? Thanks!

Example :

在此处输入图像描述

You can do this with the help of making ajax request to your php file, which will then execute your username and password and return true or fase or Other information about request.... This is the simplest way to do something on same page.

You have at least two choices:

  • AJAX request (as others suggest), that will submit the form and make proper action depending on whether this was success (eg. load private data) or error (eg. display information about incorrect username/password),
  • IFRAME containing login form , that will reload itself, not the whole window (and eventually make some action or execute some script, depending on what you need),

Use AJAX, With it. user doesn't need to reload page to communicate with server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM