Skip to main content
Home
Live to Learn!

Main navigation

  • Home
  • Learn
    • FoxPro
    • MS-DOS
    • C PRG
    • Java
    • ASP
    • Ruby on Rails
    • ASP.NET
    • E-Books
    • Exam Preparation
    • Tools
  • Blog
  • Forums
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. ASP Programs

Login form with Timeout

Book navigation

  • Displaying a message according to the time of a day and weekday.
  • Cookies Manipulation
  • Ad Rotator in ASP
  • Example Forms - Course Registration
  • Select, Insert, Update, Delete Records in Database - Employee
  • Login form with Timeout
By Karthikeyan , 19 August, 2012

Creating a asp login form which expires after particular time..
File 1 : login.asp
To show a login form. It creates a session variable t1 and sets the value to the current time (the page requested time)


<%@ Language=VBScript %>


<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<CENTER> LOGIN</CENTER>
<FORM METHOD=POST ACTION="logtest.asp" id=form1 name=form1>
<TABLE WIDTH=300
 BGCOLOR=Khaki BORDERCOLOR=Aqua ALIGN=center BORDER=1 CELLSPACING=1 CELLPADDING=1>
  	<TR>
		<TD>USERNAME</TD>
		<TD><INPUT TYPE="text" NAME="uname"></TD>
	</TR>
	<TR>
		<TD>PASSWORD</TD>
		<TD><INPUT TYPE="password" NAME="pword"></TD>
	</TR>
	
</TABLE>
 <BR>
<CENTER> <INPUT NAME=BUTTON1 TYPE=SUBMIT VALUE="SUBMIT"> </CENTER>
</FORM>
<% session("t1") = time()%>

</BODY>
</HTML>

File 2: logtest.asp
To process the input from the login form. Time from session variable t1 is checked with the current time in server.

 
<%@ Language=VBScript %>
<%
username = Request.Form("uname")
password = Request.Form ("pword")
intime = session("t1")
outtime = TIME()
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<FONT face=Arial size=10>

<%diff=DateDiff("S", intime,outtime) 
if diff > 5 then
Response.Write "Sign in form Time out <br/> <a href=login.asp>Try Again</a>"
else

if username = "" or password = "" then
Response.Write "Enter your Username & Password <br/> <a href=login.asp>Go to Login Page</a>"
else
if username ="admin" and password="pass" then
session("loggedin") = true
session("uname") = username

Response.Write "Hi," &session("uname")&"<br>"

Response.Write "You have sucessfully logged in"
else
Response.Write "Username or Password Incorrect! <br/> <a href=login.asp>Try Again</a>"
end if
end if
end if
%>
</font>
</BODY>
</HTML>
  • Add new comment

Comments

Featured Blog Posts

Convert Currency in Number to Words (Indian Rupees) - MS Excel
Foxpro Tutorial and Programs
Convert Currency in Number to Words in MS Word
Convert Currency in Number to Words (Indian Rupees) - Version 2
Best way to Use Rupee Symbol in Windows – Easy steps
Convert Currency in Number to Words - MS Access
Creating All in One Windows XP DVD with all Important Applications
RSS feed

© 2009-2025 Live to Learn.In

Terms of Use | Privacy Policy