11 Ağustos 2007 Cumartesi

Password Protect Webpages

<%
'// by Ferruh Mavituna
'// ferruh@mavituna.com
'// http://ferruh.mavituna.com

Dim ThisPage
ThisPage = Request.ServerVariables("SCRIPT_NAME")

'// Set Session + password is Case Sensitive
If Request.Form("pass") <> "" Then
If Trim(Request.Form("pass")) = "yourpassword" Then Session("level") = "ok"
End If

'// Logout (xxx.asp?logout=ok)
If Request.Querystring("logout") <> "" Then Session("level") = ""

'// Ask for Login
If Session("level") <> "ok" Then
Response.Write "<form method=""post"" action=""" & ThisPage &amp; """><input type=""password"" name=""pass"" /><input type=""submit"" value=""Login""/></form>"
Response.End

Else '// Logged + Show logout button
Response.Write "<a href=""" & ThisPage &amp; "?logout=ok"">logout(x)</a>"
End If
%>


0 Comments: