Her er et eksempel på et login system som jeg selv har lavet og bruger :
Default.asp
<%@LANGUAGE=\"VBSCRIPT\"%>
<%
Response.Expires = 0
Response.AddHeader \"PRAGMA\", \"NO-CACHE\"
%>
<!--#include virtual=\"/Connections/FmMember.inc\" -->
<html>
<head>
<title>Log in to ForMor member section</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<%
Dim YourCookiesId, CookiesId, NoCookies
YourCookiesId = Request.Cookies(\"Memberacces\")(\"YourId\")
CookiesId = Request.Cookies(\"Memberacces\")(\"CookiesId\")
NoCookies = (\"0\")
If YourCookiesId = \"\" OR CookiesId = \"\" Then
NoCookies = NoCookies + 1
End IF
If NoCookies = 1 Then
Dim fejl, FejlYourId, FejlPassword, FejlForkertPassword, FejlYourIdNotInDb
Fejl = Request.Querystring(\"Fejl\")
FejlYourId = Request.Querystring(\"FejlYourId\")
FejlPassword = Request.Querystring(\"FejlPassword\")
FejlForkertPassword = Request.Querystring(\"FejlForkertPassword\")
FejlYourIdNotInDb = Request.Querystring(\"FejlYourIdNotInDb\")
%>
<form name=\"form1\" method=\"get\" action=\"makelogin.asp\">
<table width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<div align=\"center\"><img src=\"../banner/div_pic/guld_bue_550_top.jpg\" width=\"550\" height=\"39\">
<font color=\"#FF0000\"><B>
<%If FejlYourId > 0 Or FejlPassword > 0 Then
Response.Write \"There was a problem with the information you submittet.<br>\"
End If %>
<%If FejlForkertPassword = 1 Then
Response.Write \"Password is incorect<br>\"
End If %>
<% If Fejl = 1 Then
Response.Write \"You must fill in the fields\"
End If %>
<% If FejlYourIdNotInDb > 0 Then
Response.Write \"The ID number is not in our database\"
End If %>
</B></font></div>
</td>
</tr>
</table>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td width=\"224\">Enter your Id #</td>
<td width=\"264\">
<font color=\"#FF0000\">
<%If FejlYourId > 0 Then
Response.Write \"There was a problem with your Member Id\"
End If %>
</font>
<input type=\"text\" name=\"YourId\">
</td>
</tr>
<tr>
<td width=\"224\">Enter your password</td>
<td width=\"264\">
<font color=\"#FF0000\">
<%If FejlPassword > 0 Then
Response.Write \"There was a problem with your Password\"
End If %>
</font>
<input type=\"password\" name=\"Password\">
</td>
</tr>
</table>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<div align=\"center\">
<font color=\"#FF0000\"><B>
<%If FejlYourId > 0 Or FejlPassword > 0 Then
Response.Write \"Please note that you can\'t use characters like<br>_ \' % , ; & =<br>or spaces \"
End If %>
</B></font>
</div>
</td>
</tr>
</table>
<table width=\"r%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<input type=\"submit\" name=\"Submit2\" value=\"Submit\">
</td>
</tr>
</table>
<br>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td width=\"4\">
<input type=\"radio\" name=\"RememberMe\" value=\"1\" checked>
</td>
<td width=\"484\">I want to log in every time I visit the member section (<font color=\"#FF0000\">Recommended</font>)*</td>
</tr>
<tr>
<td width=\"4\">
<input type=\"radio\" name=\"RememberMe\" value=\"2\">
</td>
<td width=\"484\">I want to be automatically logged in each time I visit the
member section **</td>
</tr>
</table>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td><img src=\"../banner/div_pic/guld_bue_550_bund.jpg\" width=\"550\" height=\"39\"></td>
</tr>
</table>
</form>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<p><font size=\"2\">* If you choose this recommended option nobody can enter
your member section unless they know your password</font></p>
<p><font size=\"2\">** If you choose this option anybody can enter your member
section if they use your computer!</font></p>
<p><font size=\"2\" color=\"#FF0000\">Please note :</font><font size=\"2\"><br>
If your browser does not support cookies you wont be able to log in to
the member section.</font></p>
</td>
</tr>
</table>
</body>
</html>
<%End If %>
<%
If NoCookies = 0 Then
Set RsCheckCookies = Conn.Execute(\"SELECT CookiesId FROM MedlemsInfo Where MedlemsIdNr = \'\" & YourCookiesId & \"\'\")
If RsCheckCookies(\"CookiesId\") = CookiesId Then
Server.Transfer \"logged_in.asp\"
Else
Response.Redirect \"re_log_in.asp?Side=/member/default.asp&BadCookiesPassword=1\" %>
<%
End If
End If
%>
makelogin.asp :
<%@LANGUAGE=\"VBSCRIPT\"%>
<%
Response.Expires = 0
Response.AddHeader \"PRAGMA\", \"NO-CACHE\"
%>
<!--#include virtual=\"/Connections/FmMember.inc\" -->
<%
Dim YourId, Password, FejlYourId, Fejl, FejlPassword, FejlYourIdNotInDb, FejlForkertPassword, FejlRememberMe, RememberMe
YourId = Request.Querystring(\"YourId\")
Password = Request.Querystring(\"Password\")
Fejl = (\"0\")
FejlYourId = (\"0\")
FejlPassword = (\"0\")
FejlYourIdNotInDb = (\"0\")
FejlForkertPassword = (\"0\")
FejlRememberMe = (\"0\")
RememberMe = Request.Querystring(\"RememberMe\")
%>
<%
If YourId = (\"\") Or Password = (\"\") Then
Fejl = Fejl + 1
End If
if instr(YourId ,\"\'\") Or _
instr(YourId ,\"&\") Or _
instr(YourId ,\",\") Or _
instr(YourId ,\";\") Or _
instr(YourId ,\"_\") Or _
instr(YourId ,\"=\") Or _
instr(YourId ,\" \") Or _
instr(lcase(YourId) ,\"select \") Or _
instr(lcase(YourId) ,\" where \") Or _
instr(lcase(YourId) ,\" or \") Or _
instr(lcase(YourId) ,\" by \") Or _
instr(lcase(YourId) ,\" insert \") Or _
instr(lcase(YourId) ,\" update \") Or _
instr(lcase(YourId) ,\" and \") Then
FejlYourId = FejlYourId + 1
End If
if instr(Password ,\"\'\") Or _
instr(Password ,\"&\") Or _
instr(Password ,\",\") Or _
instr(Password ,\";\") Or _
instr(Password ,\"_\") Or _
instr(Password ,\"=\") Or _
instr(Password ,\" \") Or _
instr(lcase(Password) ,\"select \") Or _
instr(lcase(Password) ,\" where \") Or _
instr(lcase(Password) ,\" or \") Or _
instr(lcase(Password) ,\" by \") Or _
instr(lcase(Password) ,\" insert \") Or _
instr(lcase(Password) ,\" update \") Or _
instr(lcase(Password) ,\" and \") Then
FejlPassword = FejlPassword + 1
End If
If Fejl > 0 Or FejlYourId > 0 Or FejlPassword > 0 Then
Response.Redirect \"default.asp?FejlYourId=\" & FejlYourId & _
\"&FejlPassword=\" & FejlPassword & _
\"&Fejl=\" & Fejl
End If
Set RS = conn.Execute (\"SELECT MedlemsIdNr From MedlemsInfo WHERE MedlemsIdNr =\'\" & YourId & \"\'\")
If RS.EOF Then
Response.Redirect \"default.asp?FejlYourIdNotInDb=1\"
Else
Set RS1 = conn.Execute (\"SELECT MedlemsPassword From MedlemsInfo WHERE MedlemsIdNr =\'\" & YourId & \"\'\")
If RS1(\"MedlemsPassword\") <> Password Then
FejlForkertPassword = FejlForkertPassword + 1
End If
If RememberMe = \"\" Then
FejlRememberMe = FejlRememberMe + 1
End If
If FejlYourIdNotInDb > 0 Or FejlForkertPassword > 0 Or FejlRememberMe > 0 Then
Response.Redirect \"default.asp?FejlYourIdNotInDb=\" & FejlYourIdNotInDb & _
\"&FejlForkertPassword=\" & FejlForkertPassword & _
\"&FejlRememberMe=\" & FejlRememberMe
Else
Function MakePassword(intAntaltegn)
For x = 1 To intAntalTegn
Randomize
intChooser = Int(Rnd * 2) + 1
Select Case intChooser
Case 1
intWildChar = Int(Rnd * 57) + 65
If intWildChar => 91 And intWildChar <= 96 Then
intWildChar = intWildChar + 8
End If
strPassword = strPassword & Chr(intWildChar)
Case Else
intWildChar = Int(Rnd * 9) + 1
strPassword = strPassword & intWildChar
End Select
Next
MakePassword = strPassword
End Function
CookiesId1 = MakePassword(20)
\'for at undgå 2 mennesker ender med samme CookiesId sætter vi Id nummer ind foran
CookiesId = YourId & CookiesId1
If RememberMe = (\"1\") Then
Set RS2 = conn.Execute (\"UPDATE MedlemsInfo SET CookiesId = \'\" & CookiesId & \"\' Where MedlemsIdNr = \'\" & YourId & \"\'\")
Response.Cookies(\"Memberacces\")(\"CookiesId\") = \"\" & CookiesId & \"\"
Response.Cookies(\"Memberacces\")(\"YourId\") = \"\" & YourId & \"\"
\'Response.Cookies(\"Memberacces\").Expires = dateadd(\"h\",2,now())
Response.Redirect \"logged_in.asp\"
Else
If RememberMe = (\"2\") Then
Set RS3 = conn.Execute (\"UPDATE MedlemsInfo SET CookiesId = \'\" & CookiesId & \"\' Where MedlemsIdNr = \'\" & YourId & \"\'\")
Response.Cookies(\"Memberacces\")(\"CookiesId\") = \"\" & CookiesId & \"\"
Response.Cookies(\"Memberacces\")(\"YourId\") = \"\" & YourId & \"\"
Response.Cookies(\"Memberacces\").Expires = Date+365
Response.Redirect \"logged_in.asp\"
End If
End If
End If
End If
%>
Logged_in.asp :
<%@LANGUAGE=\"VBSCRIPT\"%>
<%
Response.Expires = 0
Response.AddHeader \"PRAGMA\", \"NO-CACHE\"
%>
<!--#include virtual=\"/member/check_cookies.inc\" -->
Bla bla bla bla
Check_cookies.inc :
Denne fil inkluderes bare på alle sidcer som skal være beskyttet
<%
Dim CookiesId, YourId, Side
CookiesId = Request.Cookies(\"Memberacces\")(\"CookiesId\")
YourId = Request.Cookies(\"Memberacces\")(\"YourId\")
Side = Request.Servervariables(\"URL\") & \"?\" & Request.Querystring
If Request.Cookies(\"MemberAcces\")(\"CookiesId\") = (\"\") Then
Response.redirect \"/member/re_log_in.asp?side=\" & Side & _
\"&NoCookies=1\"
Else
%>
<!--#include virtual=\"/Connections/FmMember.inc\" -->
<%
Set RS = conn.Execute (\"Select MedlemsIdNr, CookiesId From MedlemsInfo Where MedlemsIdNr = \'\" & YourId & \"\'\")
If CookiesId <> RS(\"CookiesId\") then
Response.redirect \"/member/re_log_in.asp?side=\" & Side & _
\"&BadCookiesPassword=1\"
End If
End If
%>
re_log_in.asp :
<%@LANGUAGE=\"VBSCRIPT\"%>
<%
Response.Expires = 0
Response.AddHeader \"PRAGMA\", \"NO-CACHE\"
%>
<%
Dim fejl, FejlYourId, FejlPassword, FejlForkertPassword, BadCookiesPassword, Side, NoCookies, FejlYourIdNotInDb
Fejl = Request.Querystring(\"Fejl\")
FejlYourId = Request.Querystring(\"FejlYourId\")
FejlPassword = Request.Querystring(\"FejlPassword\")
FejlForkertPassword = Request.Querystring(\"FejlForkertPassword\")
BadCookiesPassword = Request.Querystring(\"BadCookiesPassword\")
Side = Request.Querystring(\"Side\")
NoCookies = Request.Querystring(\"NoCookies\")
FejlYourIdNotInDb = Request.Querystring(\"FejlYourIdNotInDb\")
%>
<html>
<head>
<title>You must be logged in to wiev the page.</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>
<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<form name=\"form1\" method=\"get\" action=\"re_make_login.asp\">
<table width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<div align=\"center\"><img src=\"../banner/div_pic/guld_bue_550_top.jpg\" width=\"550\" height=\"39\">
<font color=\"#FF0000\"><B>
<%If FejlYourId > 0 Or FejlPassword > 0 Then
Response.Write \"There was a problem with the information you submittet.<br><br>\"
End If %>
<%If FejlForkertPassword = 1 Then
Response.Write \"Password is incorect<br><br>\"
End If %>
<% If Fejl = 1 Then
Response.Write \"You must fill in the fields\"
End If %>
<% If BadCookiesPassword > 0 Then
Response.Write \"Your cookies password diddent match, Please log in again.\"
End If %>
<% If NoCookies > 0 Then
Response.Write \"You must be logged in to wiev this page\"
End If %>
<% If FejlYourIdNotInDb > 0 Then
Response.Write \"The ID number is not in our database\"
End If %>
</B></font></div>
</td>
</tr>
</table>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td width=\"224\">Enter your Id #</td>
<td width=\"264\">
<font color=\"#FF0000\">
<%If FejlYourId > 0 Then
Response.Write \"There was a problem with your Member Id\"
End If %>
</font>
<input type=\"text\" name=\"YourId\">
</td>
</tr>
<tr>
<td width=\"224\">Enter your password</td>
<td width=\"264\">
<font color=\"#FF0000\">
<%If FejlPassword > 0 Then
Response.Write \"There was a problem with your Password\"
End If %>
</font>
<input type=\"password\" name=\"Password\">
<input type=\"hidden\" name=\"Side\" value=\"<% = Side %>\">
</td>
</tr>
</table>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<div align=\"center\">
<font color=\"#FF0000\"><B>
<%If FejlYourId > 0 Or FejlPassword > 0 Then
Response.Write \"Please note that you can\'t use characters like<br>_ \' % , ; & =<br>or spaces \"
End If %>
</B></font>
</div>
</td>
</tr>
</table>
<table width=\"r%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<input type=\"submit\" name=\"Submit2\" value=\"Submit\">
</td>
</tr>
</table>
<br>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td width=\"4\">
<input type=\"radio\" name=\"RememberMe\" value=\"1\" checked>
</td>
<td width=\"484\">I want to log in every time I visit the member section (<font color=\"#FF0000\">Recommended</font>)*</td>
</tr>
<tr>
<td width=\"4\">
<input type=\"radio\" name=\"RememberMe\" value=\"2\">
</td>
<td width=\"484\">I want to be automatically logged in each time I visit the
member section **</td>
</tr>
</table>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td><img src=\"../banner/div_pic/guld_bue_550_bund.jpg\" width=\"550\" height=\"39\" border=\"0\"></td>
</tr>
</table>
</form>
<table width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" align=\"center\">
<tr>
<td>
<font color=\"#FF0000\"><B>
<% If BadCookiesPassword > 0 Then
Response.Write \"This error ocours only if someone else has used your member information to log in to your account or you have logged into the member section from another computer\"
End If %>
</B></font>
<p><font size=\"2\">* If you choose this recommended option nobody can enter
your member section unless they know your password</font></p>
<p><font size=\"2\">** If you choose this option anybody can enter your member
section if they use your computer!</font></p>
<p><font size=\"2\" color=\"#FF0000\">Please note :</font><font size=\"2\"><br>
If your browser does not support cookies you wont be able to log in to
the member section.</font></p>
</td>
</tr>
</table>
</body>
</html>
re_make_login.asp :
<%@LANGUAGE=\"VBSCRIPT\"%>
<%
Response.Expires = 0
Response.AddHeader \"PRAGMA\", \"NO-CACHE\"
%>
<!--#include virtual=\"/Connections/FmMember.inc\" -->
<%
Dim YourId, Password, FejlYourId, Fejl, FejlPassword, FejlYourIdNotInDb, FejlForkertPassword, FejlRememberMe, RememberMe
YourId = Request.Querystring(\"YourId\")
Password = Request.Querystring(\"Password\")
Fejl = (\"0\")
FejlYourId = (\"0\")
FejlPassword = (\"0\")
FejlYourIdNotInDb = (\"0\")
FejlForkertPassword = (\"0\")
FejlRememberMe = (\"0\")
RememberMe = Request.Querystring(\"RememberMe\")
Side = Request.Querystring(\"Side\")
%>
<%
If Side = \"\" Then
Response.Redirect \"
http://www.formor.dk/member/not_from_domaine.asp\"End If
If YourId = (\"\") Or Password = (\"\") Then
Fejl = Fejl + 1
End If
if instr(YourId ,\"\'\") Or _
instr(YourId ,\"&\") Or _
instr(YourId ,\",\") Or _
instr(YourId ,\";\") Or _
instr(YourId ,\"_\") Or _
instr(YourId ,\"=\") Or _
instr(YourId ,\" \") Or _
instr(lcase(YourId) ,\"select \") Or _
instr(lcase(YourId) ,\" where \") Or _
instr(lcase(YourId) ,\" or \") Or _
instr(lcase(YourId) ,\" by \") Or _
instr(lcase(YourId) ,\" insert \") Or _
instr(lcase(YourId) ,\" update \") Or _
instr(lcase(YourId) ,\" and \") Then
FejlYourId = FejlYourId + 1
End If
if instr(Password ,\"\'\") Or _
instr(Password ,\"&\") Or _
instr(Password ,\",\") Or _
instr(Password ,\";\") Or _
instr(Password ,\"_\") Or _
instr(Password ,\"=\") Or _
instr(Password ,\" \") Or _
instr(lcase(Password) ,\"select \") Or _
instr(lcase(Password) ,\" where \") Or _
instr(lcase(Password) ,\" or \") Or _
instr(lcase(Password) ,\" by \") Or _
instr(lcase(Password) ,\" insert \") Or _
instr(lcase(Password) ,\" update \") Or _
instr(lcase(Password) ,\" and \") Then
FejlPassword = FejlPassword + 1
End If
If Fejl > 0 Or FejlYourId > 0 Or FejlPassword > 0 Then
Response.Redirect \"re_log_in.asp?FejlYourId=\" & FejlYourId & _
\"&FejlPassword=\" & FejlPassword & _
\"&Fejl=\" & Fejl & _
\"&Side=\" & Side
End If
Set RS = conn.Execute (\"SELECT MedlemsIdNr From MedlemsInfo WHERE MedlemsIdNr =\'\" & YourId & \"\'\")
If RS.EOF Then
Response.Redirect \"re_log_in.asp?FejlYourIdNotInDb=1&Side=\" & Side
Else
Set RS1 = conn.Execute (\"SELECT MedlemsPassword From MedlemsInfo WHERE MedlemsIdNr =\'\" & YourId & \"\'\")
If RS1(\"MedlemsPassword\") <> Password Then
FejlForkertPassword = FejlForkertPassword + 1
End If
If RememberMe = \"\" Then
FejlRememberMe = FejlRememberMe + 1
End If
If FejlYourIdNotInDb > 0 Or FejlForkertPassword > 0 Or FejlRememberMe > 0 Then
Response.Redirect \"re_log_in.asp?FejlYourIdNotInDb=\" & FejlYourIdNotInDb & _
\"&FejlForkertPassword=\" & FejlForkertPassword & _
\"&FejlRememberMe=\" & FejlRememberMe & _
\"&Side=\" & Side
Else
Function MakePassword(intAntaltegn)
For x = 1 To intAntalTegn
Randomize
intChooser = Int(Rnd * 2) + 1
Select Case intChooser
Case 1
intWildChar = Int(Rnd * 57) + 65
If intWildChar => 91 And intWildChar <= 96 Then
intWildChar = intWildChar + 8
End If
strPassword = strPassword & Chr(intWildChar)
Case Else
intWildChar = Int(Rnd * 9) + 1
strPassword = strPassword & intWildChar
End Select
Next
MakePassword = strPassword
End Function
CookiesId1 = MakePassword(20)
\'for at undgå 2 mennesker ender med samme CookiesId sætter vi Id nummer ind foran
CookiesId = YourId & CookiesId1
If RememberMe = (\"1\") Then
Set RS2 = conn.Execute (\"UPDATE MedlemsInfo SET CookiesId = \'\" & CookiesId & \"\' Where MedlemsIdNr = \'\" & YourId & \"\'\")
Response.Cookies(\"Memberacces\")(\"CookiesId\") = \"\" & CookiesId & \"\"
Response.Cookies(\"Memberacces\")(\"YourId\") = \"\" & YourId & \"\"
Response.Redirect \"\" & Side
Else
If RememberMe = (\"2\") Then
Set RS3 = conn.Execute (\"UPDATE MedlemsInfo SET CookiesId = \'\" & CookiesId & \"\' Where MedlemsIdNr = \'\" & YourId & \"\'\")
Response.Cookies(\"Memberacces\")(\"CookiesId\") = \"\" & CookiesId & \"\"
Response.Cookies(\"Memberacces\")(\"YourId\") = \"\" & YourId & \"\"
Response.Cookies(\"Memberacces\").Expires = Date+365
Response.Redirect \"\" & Side
End If
End If
End If
End If
%>