开发者

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 a开发者_StackOverflow中文版nd 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:

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


Use Ajax! the idea is to use XmlHttpRequest objects to send requests back to the server and get response .

Google for PHP ajax login:

  1. http://www.roseindia.net/ajax/ajaxlogin/ajax-login-program.shtml
  2. http://evolt.org/ajax_login_system

Using jQuery:

  1. http://www.chazzuka.com/php-ajax-login-form-using-jquery-82/
  2. http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.html
  3. http://ajaxmint.com/2009/12/php-ajax-login-form-using-jquery/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜