asp password protection
Asp Password Protection for website
Original Author: Faisal Arif
Inputs
name the files accordingly as mentioned in the source code
Code
password.asp
<%@ LANGUAGE="VBSCRIPT" %>
--------------------------------------------------------------------------------
engine.asp
-------------
<%@ LANGUAGE="VBSCRIPT" %>
<%
' Connects and opens the text file
' DATA FORMAT IN TEXT FILE= "username
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.OpenTextFile(Server.MapPath("pathpathpathpath") & "passwords.txt")
' Scan the text file to determine if the user is legal
WHILE NOT MyTextFile.AtEndOfStream
' If username and password found
IF MyTextFile.ReadLine = Request.form("username") & " " & Request.form("password") THEN
' Close the text file
MyTextFile.Close
' Go to login success page
Session("GoBack")=Request.ServerVariables("SCRIPT_NAME")
Response.Redirect "inyougo.asp"
Response.end
END IF
WEND
' Close the text file
MyTextFile.Close
' Go to error page if login unsuccessful
Session("GoBack")=Request.ServerVariables("SCRIPT_NAME")
Response.Redirect "invalid.asp"
Response.end
%>
------------
invalid.asp
-----
<%@ LANGUAGE="VBSCRIPT" %>
You have entered an invalid username or password.
Try to log in again
------
inyougo.asp
------
<%@ LANGUAGE="VBSCRIPT" %>
You have now entered the password protected page.
-------
passwords.txt
----
gates bill
burns joe
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.