Search Tools Links Login

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" %>



   Password.asp


  


     User Name:
    


     Password:
    


    
  






--------------------------------------------------------------------------------
engine.asp
-------------
<%@ LANGUAGE="VBSCRIPT" %>
<%
   ' Connects and opens the text file
   ' DATA FORMAT IN TEXT FILE= "usernamepassword"
   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" %>



invalid.asp


You have entered an invalid username or password.


Try to log in again



------
inyougo.asp
------
<%@ LANGUAGE="VBSCRIPT" %>



   In You Go


   You have now entered the password protected page.


-------
passwords.txt
----
gates bill
burns joe

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 97 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.