Hi
I want to set-up a page which if the user logs in successfully wil redirect them to another page or send them to a noaccess.asp page
Using our CMS system there are already two files logon.asp and noaccess.asp as shown below
I want to create my own page say LegLogin.asp and use/call logon.asp.
any help much appreciated
kim
logon.asp
<%@ LANGUAGE="VBSCRIPT" %>
<!--#INCLUDE FILE="includes/adovbs.inc"-->
<%
Response.Expires = -1
NTUser = UCase("" & Request.ServerVariables("AUTH_USER"))
Dim Page, DBConn, RST, SQL, errMessage
Dim mIDValid, ml, err, invalidChars
err = 0
' The page we need to return to should be passed in
' If not we need to go back to the home page
Page = "" & Request("Page")
if len(Page) = 0 Then Page = "./"
' The user has logged on if they no longer has public (1) access rights
If len("" & Session("mID")) > 0 then Response.Redirect page
if request.Form("submitted") <> 1 and len(NTUser) > 0 and len("" & Session("mID")) = 0 Then
sql = "SELECT Mb_FIRSTNAME, Mb_Lastname, mb_group, MB_EMAIL FROM Membership Where mb_authtype=1 and (mb_domain + '\' + mb_member) = '" & NTUser & "'"
Set DBConn = Server.CreateObject ("ADODB.Connection")
Set rst = Server.CreateObject ("ADODB.Recordset")
DBConn.Open Application("DSN")
rst.Open sql, DBConn, , , adCmdText
if not rst.EOF then
memID = right(NTUser, len(NTUser) - instr(1, NTUser, "\"))
Session("fname") = rst("Mb_FIRSTNAME")
Session("sname") = rst("Mb_Lastname")
Session("mID") = memID
Session("mEmail") = rst("MB_EMAIL")
Session("rights") = rst("mb_group") or 1
Response.Redirect page
else
err = 6
end if
rst.Close
DBConn.Close
end if
mIDValid = False
ml = False
If Request.form("submitted") = 1 Then
Dim number, mail
memID = Request.Form("memberID")
pass = Request.Form("password")
If Len(memID) > 0 Then
If Len(memID) < 3 Or Len(memID) > 50 Then
mIDValid = False
err = 2
Else
mIDValid = True
End If
Else
err = 1
End If
If mIDValid and Len(pass) > 0 Then
If len(pass) > 50 then
err = 4
ml = false
Else
ml = True
End If
Else
if err = 0 then
err = 3
ml = false
end if
End If
If mIDValid = True AND ml = True Then
Dim maccess, norecs
Set DBConn = Server.CreateObject ("ADODB.Connection")
Set rst = Server.CreateObject ("ADODB.Recordset")
sql = "SELECT MB_PASSWORD, Mb_FIRSTNAME, Mb_Lastname, mb_group, MB_EMAIL FROM Membership Where mb_authtype=0 and mb_member = '" & memID & "' AND mb_password = '" & pass & "'"
DBConn.Open Application("DSN")
rst.Open sql, DBConn, , , adCmdText
norecs = rst.EOF
if not rst.EOF then
maccess = rst("mb_group")
mFName = rst("Mb_FIRSTNAME")
mSName = rst("Mb_Lastname")
mail = rst("MB_EMAIL")
password = rst("MB_PASSWORD")
end if
rst.Close
if norecs Then
' Not a member so check member groups
sql = "SELECT u_title, u_bit FROM Usergroups Where u_user = '" & memID & "' AND u_password = '" & pass & "'"
rst.Open sql, DBConn, , , adCmdText
norecs = rst.EOF
if not rst.EOF then
maccess = 2^(cint(rst("u_bit"))-1)
mFName = rst("u_title")
mSName = ""
end if
rst.Close
End if
set rst = nothing
DBConn.Close
set dbconn = nothing
If Not norecs Then
if (Request.Form("saveme") = "on") then
Response.Cookies("ud")("un") = memID
Response.Cookies("ud")("ue") = mail
Response.Cookies("ud")("up") = password
Response.Cookies("ud").Expires = DateAdd("m", 1, Date)
Response.Cookies("ud").path = "/"
else
Response.Cookies("ud")("un") = ""
Response.Cookies("ud")("ue") = ""
Response.Cookies("ud").Expires = "1/1/1980"
end if
Session("fname") = mFName
Session("sname") = mSName
Session("mID") = memID
Session("mEmail") = mail
Session("rights") = maccess or 1
Response.Redirect page
Else
err = 5
End If
End IF
End If
dim errstr
If err > 0 Then
Select Case err
Case 1
errstr = "Please type in your Member ID!"
Case 2
errstr = "Invalid Member ID!"
Case 3
errstr = "Please type in your password!"
Case 4
errstr = "Invalid password"
Case 5
errstr = "The Member ID and password you typed in do not exist!"
case 6
errstr = "Your NT user account is not a registered member of this site.<br>Please log on using another user."
End Select
End If
%>
<html>
<head>
<meta name="vs_targetSchema" content=" <title>Logon</title>
</head>
<body leftmargin="0" marginheight="0" marginwidth="0" topmargin="0" onload="loginForm.memberID.focus();">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr><td> </td></tr>
<tr><td align="center">
<form name="loginForm" action="logon.asp" method="post">
<table border="0" cellpadding="2" cellspacing="0" bgcolor="darkgray" width="208">
<tr>
<td><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="darkgray">
<tr bgcolor="darkgray">
<td align="left"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;"> Log
In</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table border="0" cellpadding="3" cellspacing="0" bgcolor="lightgrey">
<%If err <> 0 Then%>
<tr>
<td colspan="3" align="center"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;"><% = errstr%></span></td>
</tr>
<%End If%>
<tr>
<td nowrap><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;"> Member
ID</span></td>
<td width="5"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;">:</span></td>
<td><input style="width:129;" size="16" type="textbox" id="memberID" name="memberID" value="<%=Request.Cookies("ud")("un")%>"></td>
</tr>
<tr>
<td><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;"> Password</span></td>
<td width="5"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;">:</span></td>
<td><input style="width:129;" size="16" type="password" id="password" name="password" value="<%=Request.Cookies("ud")("up")%>"></td>
</tr>
<tr>
<td colspan="2" nowrap><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;"><input type="checkbox" checked="true" name="saveme" value="on" id="saveme"><label for="saveme">Remember
Details</label></span></td>
<td align="right"><input type="submit" value="Go >>" id="submit1" name="submit1"></td>
</tr>
</table>
</td>
</tr>
</table>
<a href="authenticate.asp?page=<%=Request("Page")%>" style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;">Authenticate Me</a>
<input type="hidden" name="page" value="<%=page%>"><input type="hidden" name="submitted" value="1">
</form>
</td></tr></table>
</body>
noaccess.asp
<%@ Language=VBScript %>
<%
Dim Page
Page = "" & Request("Page")
if len(Page) = 0 Then Page = "./"
%>
<HTML>
<HEAD>
<meta name=vs_targetSchema content="<style type=text/css>
DIV {font-family:Verdana, Arial; font-size:9pt;}
</style>
<title>No Access</title>
</HEAD>
<BODY>
<DIV>You do not have permission to view this page.</DIV>
<DIV> </DIV>
<DIV><A href="logoff.asp?page=<%=Page%>">Log Off</A></DIV>
</BODY>
</HTML>
I want to set-up a page which if the user logs in successfully wil redirect them to another page or send them to a noaccess.asp page
Using our CMS system there are already two files logon.asp and noaccess.asp as shown below
I want to create my own page say LegLogin.asp and use/call logon.asp.
any help much appreciated
kim
logon.asp
<%@ LANGUAGE="VBSCRIPT" %>
<!--#INCLUDE FILE="includes/adovbs.inc"-->
<%
Response.Expires = -1
NTUser = UCase("" & Request.ServerVariables("AUTH_USER"))
Dim Page, DBConn, RST, SQL, errMessage
Dim mIDValid, ml, err, invalidChars
err = 0
' The page we need to return to should be passed in
' If not we need to go back to the home page
Page = "" & Request("Page")
if len(Page) = 0 Then Page = "./"
' The user has logged on if they no longer has public (1) access rights
If len("" & Session("mID")) > 0 then Response.Redirect page
if request.Form("submitted") <> 1 and len(NTUser) > 0 and len("" & Session("mID")) = 0 Then
sql = "SELECT Mb_FIRSTNAME, Mb_Lastname, mb_group, MB_EMAIL FROM Membership Where mb_authtype=1 and (mb_domain + '\' + mb_member) = '" & NTUser & "'"
Set DBConn = Server.CreateObject ("ADODB.Connection")
Set rst = Server.CreateObject ("ADODB.Recordset")
DBConn.Open Application("DSN")
rst.Open sql, DBConn, , , adCmdText
if not rst.EOF then
memID = right(NTUser, len(NTUser) - instr(1, NTUser, "\"))
Session("fname") = rst("Mb_FIRSTNAME")
Session("sname") = rst("Mb_Lastname")
Session("mID") = memID
Session("mEmail") = rst("MB_EMAIL")
Session("rights") = rst("mb_group") or 1
Response.Redirect page
else
err = 6
end if
rst.Close
DBConn.Close
end if
mIDValid = False
ml = False
If Request.form("submitted") = 1 Then
Dim number, mail
memID = Request.Form("memberID")
pass = Request.Form("password")
If Len(memID) > 0 Then
If Len(memID) < 3 Or Len(memID) > 50 Then
mIDValid = False
err = 2
Else
mIDValid = True
End If
Else
err = 1
End If
If mIDValid and Len(pass) > 0 Then
If len(pass) > 50 then
err = 4
ml = false
Else
ml = True
End If
Else
if err = 0 then
err = 3
ml = false
end if
End If
If mIDValid = True AND ml = True Then
Dim maccess, norecs
Set DBConn = Server.CreateObject ("ADODB.Connection")
Set rst = Server.CreateObject ("ADODB.Recordset")
sql = "SELECT MB_PASSWORD, Mb_FIRSTNAME, Mb_Lastname, mb_group, MB_EMAIL FROM Membership Where mb_authtype=0 and mb_member = '" & memID & "' AND mb_password = '" & pass & "'"
DBConn.Open Application("DSN")
rst.Open sql, DBConn, , , adCmdText
norecs = rst.EOF
if not rst.EOF then
maccess = rst("mb_group")
mFName = rst("Mb_FIRSTNAME")
mSName = rst("Mb_Lastname")
mail = rst("MB_EMAIL")
password = rst("MB_PASSWORD")
end if
rst.Close
if norecs Then
' Not a member so check member groups
sql = "SELECT u_title, u_bit FROM Usergroups Where u_user = '" & memID & "' AND u_password = '" & pass & "'"
rst.Open sql, DBConn, , , adCmdText
norecs = rst.EOF
if not rst.EOF then
maccess = 2^(cint(rst("u_bit"))-1)
mFName = rst("u_title")
mSName = ""
end if
rst.Close
End if
set rst = nothing
DBConn.Close
set dbconn = nothing
If Not norecs Then
if (Request.Form("saveme") = "on") then
Response.Cookies("ud")("un") = memID
Response.Cookies("ud")("ue") = mail
Response.Cookies("ud")("up") = password
Response.Cookies("ud").Expires = DateAdd("m", 1, Date)
Response.Cookies("ud").path = "/"
else
Response.Cookies("ud")("un") = ""
Response.Cookies("ud")("ue") = ""
Response.Cookies("ud").Expires = "1/1/1980"
end if
Session("fname") = mFName
Session("sname") = mSName
Session("mID") = memID
Session("mEmail") = mail
Session("rights") = maccess or 1
Response.Redirect page
Else
err = 5
End If
End IF
End If
dim errstr
If err > 0 Then
Select Case err
Case 1
errstr = "Please type in your Member ID!"
Case 2
errstr = "Invalid Member ID!"
Case 3
errstr = "Please type in your password!"
Case 4
errstr = "Invalid password"
Case 5
errstr = "The Member ID and password you typed in do not exist!"
case 6
errstr = "Your NT user account is not a registered member of this site.<br>Please log on using another user."
End Select
End If
%>
<html>
<head>
<meta name="vs_targetSchema" content=" <title>Logon</title>
</head>
<body leftmargin="0" marginheight="0" marginwidth="0" topmargin="0" onload="loginForm.memberID.focus();">
<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr><td> </td></tr>
<tr><td align="center">
<form name="loginForm" action="logon.asp" method="post">
<table border="0" cellpadding="2" cellspacing="0" bgcolor="darkgray" width="208">
<tr>
<td><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="darkgray">
<tr bgcolor="darkgray">
<td align="left"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;"> Log
In</span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><table border="0" cellpadding="3" cellspacing="0" bgcolor="lightgrey">
<%If err <> 0 Then%>
<tr>
<td colspan="3" align="center"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;"><% = errstr%></span></td>
</tr>
<%End If%>
<tr>
<td nowrap><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;"> Member
ID</span></td>
<td width="5"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;">:</span></td>
<td><input style="width:129;" size="16" type="textbox" id="memberID" name="memberID" value="<%=Request.Cookies("ud")("un")%>"></td>
</tr>
<tr>
<td><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;"> Password</span></td>
<td width="5"><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000; font-weight:bold;">:</span></td>
<td><input style="width:129;" size="16" type="password" id="password" name="password" value="<%=Request.Cookies("ud")("up")%>"></td>
</tr>
<tr>
<td colspan="2" nowrap><span style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;"><input type="checkbox" checked="true" name="saveme" value="on" id="saveme"><label for="saveme">Remember
Details</label></span></td>
<td align="right"><input type="submit" value="Go >>" id="submit1" name="submit1"></td>
</tr>
</table>
</td>
</tr>
</table>
<a href="authenticate.asp?page=<%=Request("Page")%>" style="font-family:Arial,Tahoma,Helvetica; font-size:9pt; color:000000;">Authenticate Me</a>
<input type="hidden" name="page" value="<%=page%>"><input type="hidden" name="submitted" value="1">
</form>
</td></tr></table>
</body>
noaccess.asp
<%@ Language=VBScript %>
<%
Dim Page
Page = "" & Request("Page")
if len(Page) = 0 Then Page = "./"
%>
<HTML>
<HEAD>
<meta name=vs_targetSchema content="<style type=text/css>
DIV {font-family:Verdana, Arial; font-size:9pt;}
</style>
<title>No Access</title>
</HEAD>
<BODY>
<DIV>You do not have permission to view this page.</DIV>
<DIV> </DIV>
<DIV><A href="logoff.asp?page=<%=Page%>">Log Off</A></DIV>
</BODY>
</HTML>