Logon
<%
on error resume next
'----------
'initialise
'----------
vl_scriptname = "LOGON_F.ASP"
vl_errpage = "NO"
vg_admindisabled = "NO"
'--------------------------------------------------
'call subroutine to check is site is admin disabled
'--------------------------------------------------
call checkAdminDisabled
if err.number <> 0 then
vl_errpage = "YES"
vl_errdets = vl_scriptname & "^" & err.number & "^" & err.description
elsif vg_admindisabled = "YES" then
vl_errpage = "YES"
vl_errdets = vl_scriptname & "^Admin Disabled"
end if
on error goto 0
'---------------------------------------------
're-direct to error page or display logon form
'---------------------------------------------
if vg_errpage = "YES" then%>
<%else%>
Logon
Please enter the required information below.
<%end if%>
<%
'-----------
'subroutines
'-----------
Sub checkAdminDisabled
'check whether site is admin disabled, if so load vg_admindisabled = YES
end sub
%>
*****************************************************
Javascript source, LOGON_F.JS, to validate form input
*****************************************************
function pageInit () {
document.FRM_LOGON.ID.focus();
}
function validateForm(theForm)
{
//-------------------------
//validate Account ID field
//-------------------------
if (theForm.ID.value == "") {
alert("The 'Account ID' field is mandatory, you must input a value.");
theForm.ID.focus();
return (false);
}
if (theForm.ID.value.length < 6) {
alert("The 'Account ID' field minimum size = 6 characters, maximum size = 12 characters.");
theForm.ID.focus();
return (false);
}
if (theForm.ID.value.length > 12) {
alert("The 'Account ID' field minimum size = 6 characters, maximum size = 12 characters.");
theForm.ID.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = theForm.ID.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++) {
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++) {
if (ch == checkOK.charAt(j)) {
break;
}
}
if (j == checkOK.length) {
allValid = false;
break;
}
}
if (!allValid) {
alert("The 'Account ID' field can only contain letters and numbers.");
theForm.ID.focus();
return (false);
}
//-------------------------------
//validate Account Password field
//-------------------------------
if (theForm.APSW.value == theForm.ID.value) {
alert("The 'Account Password' field cannot contain the same value as the 'Account ID' field.");
theForm.APSW.focus();
return (false);
}
if (theForm.APSW.value == "") {
alert("The 'Account Password' field is mandatory, you must input a value.");
theForm.APSW.focus();
return (false);
}
if (theForm.APSW.value.length < 6) {
alert("The 'Account Password' field minimum size = 6 characters, maximum size = 12 characters.");
theForm.APSW.focus();
return (false);
}
if (theForm.APSW.value.length > 12) {
alert("The 'Account Password' field minimum size = 6 characters, maximum size = 12 characters.");
theForm.APSW.focus();
return (false);
}
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var checkStr = theForm.APSW.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++) {
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++) {
if (ch == checkOK.charAt(j)) {
break;
}
}
if (j == checkOK.length) {
allValid = false;
break;
}
}
if (!allValid) {
alert("The 'Account Password' field can only contain letters and numbers.");
theForm.APSW.focus();
return (false);
}
return (true);
}
******************************************
Logon form processing script, LOGON_FP.ASP
******************************************
<%Response.buffer = true%>
Logon
<%
on error resume next
'----------
'initialise
'----------
vg_script = "LOGON_FP.ASP"
vg_aid = Request.QueryString("ID")
vg_apsw = Request.QueryString("APSW")
vg_logonok = "NO"
vl_errpage = "NO"
'-----------------------------------
'call subroutine to check logon dets
'-----------------------------------
call checkLogon
if err.number <> 0 then
vl_errpage = "YES"
vl_errdets = vl_scriptname & "^" & err.number & "^" & err.description
elsif vg_logonok = "NO" then
vl_errpage = "YES"
vl_errdets = vl_scriptname & "^Bad Logon"
end if
on error goto 0
'------------------------------------------------
're-direct to error page or application main page
'------------------------------------------------
if vg_errpage = "YES" then%>
<%else%>
<%end if%>
<%
'-----------
'subroutines
'-----------
Sub checkLogon
'check logon dets in database, load vg_logonok = YES if ok
end sub
%>