Session Variables
Session Variables
Session("VARIABLE NAME")=expression
e.g.
Session("COUNT")="1"
e.g.
isEmpty(Session("COUNT"))
<html>
<head>
<title>Session Variables : Page Counter</title>
</head>
<body bgcolor="#ccffee">
<%
Dim cnt
if (isEmpty(Session("COUNT"))) then
Session("COUNT")="1"
cnt="1"
else
cnt=Session("COUNT")
cnt=cnt+1
Session("COUNT")=cnt
end if
Question :
<html>
<head>
<title>Session variables : Access Denied</title>
</head>
<body bgcolor="#ccffee">
<form name="myform" action="valid.asp">
<center>
<br>
<br>
<marquee>www.PaceInfotech.com</marquee>
<br>
<table border=2>
<tr>
<th colspan=2>Login Details</th>
</tr>
<tr>
<th>User Name :</th>
<td><input type="text" name="txtuname" size=30></td>
</tr>
<tr>
<th>Password : </th>
<td><input type=password name="txtpass"
size=30></td>
</tr>
<tr>
<td colspan=2><pre> <input type=submit> <input
type=reset></td>
</tr>
</table>
</center>
</form>
</body>
</html>
<html>
<head>
<title>Validation</title>
</head>
<body bgcolor="#ccffee">
<%
Dim uname,upass
uname=Request.QueryString("txtuname")
upass=Request.QueryString("txtpass")
Response.Write("<center>")
Response.Write("Welcome , Administrator <br>")
Response.Write("<a href=gal.asp>Start</a>")
else
Response.Write("Invalid User Name or Password")
end if
%>
</body>
</html>
<html>
<head>
<title>Photo Gallary</title>
</head>
<body bgcolor="#ccffee">
<%
if(isEmpty(Session("USERS"))) then
Response.Write("Access Denied")
else
Response.Write("<center>")
Response.write("<br><br><Marquee><h3>Photo
Gallary</h3></marquee>")
Response.Write("<br><br><img src=car.jpg
height=100 width=100><a href=photo.asp>Cars</a>")
Response.Write("<br><br><img src=actor.jpg
height=100 width=100><a href=photo.asp>Actors</a>")
Response.Write("<br><br><img src=god.jpg
height=100 width=100><a href=photo.asp>God </a>")
Response.Write("<br><br><img src=holly.jpg
height=100 width=100><a
href=photo.asp>Hollywood</a>")
Response.Write("</center>")
end if
%>
</body>
</html>
Q . Desing the following application
<html>
<head>
<title>Employee Information System</title>
</head>
<body background=bg_057.gif>
<%
'Maintain the employees record in array
Dim empid(5),names(5),salary(5)
empid(1)="101"
names(1)="Kapil"
salary(1)="18900"
empid(2)="102"
names(2)="Lalit"
salary(2)="19200"
empid(3)="103"
names(3)="Vinay"
salary(3)="9000"
empid(4)="104"
names(4)="Sudeep"
salary(4)="8900"
empid(5)="105"
names(5)="Harsh"
salary(5)="7900"
Dim rno
if (isEmpty(Session("RECNO"))) then
'place record pointer on the first record
rno="1"
Session("RECNO")="1"
else
'determine on which button the user have clicked
Dim bname
bname=Request.QueryString("cmdbutton")
rno=Session("RECNO")
if bname="Next" then
rno=rno+1
if rno>5 then
rno=1
end if
else
if bname="Previous" then
rno=rno-1
if rno<1 then
rno=5
end if
else
if bname="First" then
rno=1
else
rno=5
end if
end if
end if
Session("RECNO")=rno
end if
%>
<br>
<img src=100l.jpg>
<br>
<br>
<center>
<form name="myform" action="ems.asp">
<img src=bar_119.gif>
<br>
<br>
<table border=2>
<tr>
<th colspan=2>Employee Information System</th>
</tr>
<tr>
<th align=left>Employee Id</th>
<td><input type=text name="txtempid" size=30 value=<
%= empid(rno) %> disabled></td>
</tr>
<tr>
<th align=left>Name</th>
<td><input type=text name="txtname" size=30 value=<
%= names(rno) %> disabled></td>
</tr>
<tr>
<th align=left>Salary</th>
<td><input type=text name="txtsalary" size=30 value=<
%= salary(rno) %> disabled></td>
</tr>
<tr>
<td colspan=2><pre> <input type=submit
name=cmdbutton value=First> <input type=submit
name=cmdbutton value=Previous> <input type=submit
name=cmdbutton value=Next> <input type=submit
name=cmdbutton value=Last> </td>
</tr>
</table>
<br>
<br>
<img src=bar_119.gif>
</form>
</center>
</body>
</html>