Introduction
This article explains the best way to implement a simple login form to check account information and authenticate a user. If the user details exist in the database then the user is redirected to a welcome page, otherwise, we should instead display "Invalid Username/Password".
First I created a database EmpDetail and now I created a table in this database.
Query Code
- create table Login_Info
- (
- Emp_Name varchar(50),
- Passwrd varchar(50)
- )
Now Insert some Data in LoginDetail table.
- insert into Login_Info values('Sharad','sharad')
- insert into Login_Info values('Manish','manish')
Select * from Login_Info
Now the following procedure is used.
Step 1
Open Visual Studio 2012 and click "File" -> "New" -> "Project...". A window is opened. In this window, click "HTML Application for TypeScript" under Visual C#.
Give the name of your application as "Login" and then click "Ok".
Step 2
After this session the project has been created; a new window is opened on the right side. This window is called the Solution Explorer. The Solution Explorer contains the ts file, js file, and css file.
![login-img.jpg]()
Enter the username and password and then click on the Login button.
The user is redirected to the "WelcomPage.html" page.
Output 2
If we enter the wrong UserName or Password then:
Output 4
If you enter a UserName and Password and then click on the "Cancel" button:
After clicking on the "Cancel" button:
For more information, download the attached sample application.