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:

Use Ajax! the idea is to use
XmlHttpRequestobjects to send requests back to the server and get response .Google for PHP ajax login:
Using jQuery: