简体   繁体   中英

How to login to a website using login popup made by using javascript?

In my website, there is a login button. When a user clicks on that a popup pops up which asks for username and password from a user. Now i want that popup to work like following:

1- if user gives wrong username and password then popup disappears and an alert comes to tell user that wrong username or password is entered. try again.

2- if username and password is right then popup should be disappeard and main page should be redirected to user home page.

How can i do that using javascript.

Thanks in advance.

You want whole code? Or just conception?

You're looking for some Ajax stuff. I think your login data is in a database (if not, then it doesn't make any sense, because everyone could simply read the login data)

I recommend you to search for some Ajax tutorials. Ajax is a technique to load content dynamically via javascript. Which means: after sending username + password to a server, it will response with success or failure, which you can use on your current page to display the error or success message.

Jquery is an easy-to-use javascript framework, which also supports Ajax calls.

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