Classic ASP code for a Standard Login Page with cookies for remebering the location ID:
=============================================
<%
'Set MyConn =Server.CreateObject("ADODB.Connection")
'MyConn.open="provider=MSDAORA;data source=xxx; user id=yyy;password=zzzz"
Session.Contents.RemoveAll
%>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function validateuser()
{
if (form1.staff_no=="")
{
alert("Please Enter Staff No");
return false;
}
if (form1.user_password.value=="")
{
alert("Please Enter Password");
form1.user_password.focus();
return false;
}
if (form1.location_id.value=="")
{
alert("Please Select the Location");
return false;
}
}
</script>
<style>
.online_outer_container {
text-align:center; MARGIN: 0px auto; WIDTH: 800px
}
.online_inner_container {
WIDTH: 100%; PADDING-TOP: 20px; HEIGHT: 100%; BACKGROUND-COLOR: #ffffff
}
</style>
</head>
<body class="online_body">
<div class="online_outer_container">
<div align="left" style="clear:both">
<a href="../index3.asp">mysite Home</a>
</div>
<div class="online_inner_container">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<img src="../IMAGES/mybanner.jpg" border="0"/>
</td>
</tr>
</table>
<!--#####alert message starts-->
<script>
window.onload=function()
{alert_result_msg();}
</script>
<script language="javascript">
function alert_result_msg(){
if (FormResultMsg.resultMsg.value !=""){
alert(FormResultMsg.resultMsg.value);
}
}
</script>
<form name="FormResultMsg">
<input type="hidden" name="resultMsg" value="<%=request("result")%>">
</form>
<!--#####alert message ends-->
<br>
<%
'''' REMEMBER ME
remember_user=request.cookies("remember_user")
if remember_user="yes" then
pass_word=request.cookies("user_password")
location_id=request.cookies("location_id")
staff_no=request.cookies("staff_no")
end if
'''''''''''''''''''''''''''''''''
%>
<table width="400" align=center cellpadding="5" style="border:5px; border-style: outset;padding:25px;margin:25px">
<tr>
<td>
<table style="margin:50px;">
<tr>
<td colspan="2" align="center" style="font:bold 15px arial;color:#808080">
Login by user
<br>
<br>
</td>
</tr>
<form name="form1" action="user_lv.asp" onSubmit="javascript:return validateuser();" method="post">
<input type="hidden" name=user_group value="user" >
<tr>
<td align="right" style="text-align:right;margin-right:20px;font:normal 12px arial;color:#336699">
User ID
</td>
<td >
<input type=text name="staff_no" size="20" maxlength="20" style="font:bold 14px arial;color:#336699">
</td>
</tr>
<tr >
<td align="right" style="text-align:right;margin-right:20px;font:normal 12px arial;color:#336699">
Password
</td>
<td >
<input type="password" name="user_password" maxlength="20" value="<%=user_password%>" size="20" style="font:bold 14px arial;color:#336699">
</td>
</tr>
<tr>
<td align="right" style="text-align:right;margin-right:20px;font:normal 12px arial;color:#336699">
Exam Centre
</td>
<td >
<select name="location_id" style="font:bold 14px arial;color:#336699">
<option value="">--select--</option>
<%
set objRsIns=myconn.execute("select * from table1 where is_deleted=0 order by location_name")
if not objRsIns.eof then
while not objRsIns.eof
if trim(objRsIns("location_id"))=trim(request("location_id")) then%>
<option value="<%=objRsIns("location_id")%>" selected ><%=objRsIns("location_name")%></option>
<%elseif location_id=objRsIns("location_id") then %>
<option value="<%=objRsIns("location_id")%>" selected ><%=objRsIns("location_name")%></option>
<%else%>
<option value="<%=objRsIns("location_id")%>" ><%=objRsIns("location_name")%></option>
<%end if%>
<%
objRsIns.movenext
wend
end if
%>
</select>
</td>
</tr>
<tr >
<td colspan="2" align=center >
<input type="submit" value="Login" name="bnSave" style="font:bold 18px arial;color:#336699">
</tr>
<tr >
<td colspan=2 >
<%if remember_user="yes" then%>
<input type=checkbox name="remember_user" value="yes" checked >
<%else%>
<input type=checkbox name="remember_user" value="yes" >
<%end if%>
<span class="mysite_very_small">
Remember my Location in this PC
</span>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<br><br><br>
</div>
</div>
<script language="JavaScript" type="text/javascript" src="../includes/wz_tooltip.js"></script>
</body>
</html>
No comments:
Post a Comment