Click to See Complete Forum and Search --> : simple login .asp recieves error message


dondmcg
10-06-2003, 01:21 PM
I have set up a login page with asp that is password protected.
The five files : passord.asp, password.txt, engine.asp, invalid.asp and the page to be accessed urin.asp all reside in the same directory. When I log in to the password page I keep recieving the error message:

Microsoft VBScript runtime error '800a004c'

Path not found

/engine.asp, line 8

----------------------------------------------------------------------

this is my engine code :

<!--- This example is the simple engine system


<%@ LANGUAGE="VBSCRIPT" %>

<%
' Connects and opens the text file
' DATA FORMAT IN TEXT FILE= "username<SPACE>password"

Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
Set MyTextFile=MyFileObject.OpenTextFile(Server.MapPath("\user\htdocs") & "\password.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 "urin.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

%> --->
----------------------------------------------------------------------
This is my password code :
<!--- This example is the simple login system

<%@ LANGUAGE="VBSCRIPT" %>


<html>
<HEAD><title>Password.asp</title>
LINK REL=STYLESHEET TYPE="text/css" HREF="css1.css"></HEAD>
<BODY marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
<table border=0 valign=top cellpadding=0 cellspacing=0 width=100% height=100% bgcolor=#225E90>
<tr>
<td><table border=0 valign=top cellpadding=0 cellspacing=0 width=300px height=100%>
<tr>
<td width=181px bgcolor=#225E90><img src="images/spacer2.gif"></td>
<td width=119px bgcolor=white align=left valign=center><a href="webdesign.html"><font face="arial" size=1 weight=bold color=#225E90>&nbsp;webdesign</font></a><br><br>
<a href="wama.html"><font face="arial" size=1 weight=bold color=#225E90>&nbsp;animation</font></a><br><br>
<a href="password.asp"><font face="arial" size=1 weight=bold color=#225E90>&nbsp;directory</font></a><br><br>
<a href="contact.html"><font face="arial" size=1 weight=bold color=#225E90>&nbsp;contact</font></a><br><br>
<a href="index.html"><font face="arial" size=1 weight=bold color=#225E90>&nbsp;home</font></a><br><br></td>
</tr>
</table></td>
<td><table border=0 valign=top align=left cellpadding=0 cellspacing=10 width=500px bgcolor=#225E90>
<tr>
<td width=px height=px align=center valign=bottom>



<FORM ACTION="engine.asp" NAME="form1" METHOD="post"><TABLE bgcolor=white ALIGN=CENTER BORDER=0>
<TR>
<TD ALIGN="right">Login:</TD>
<TD><INPUT TYPE="text" NAME="username"></INPUT></TD>
</TR>
<TR>
<TD ALIGN="right">Password:</TD>
<TD><INPUT TYPE="password" NAME="password"></INPUT></TD>
</TR>
<TR>
<TD ALIGN="right"></TD>
<TD><INPUT TYPE="submit" VALUE="Login"></INPUT>
<INPUT TYPE="reset" VALUE="Reset"></INPUT>
</TD>
</TR>
</TABLE>
</FORM></td>






</tr>
</table></td>
<td width=100%><img src="images/spacer2.gif"></td>
</table>
</BODY>
</html> --->

----------------------------------------------------------------------
Can anyone tell me why?

rdoekes
10-06-2003, 04:31 PM
Server.MapPath("\user\htdocs") & "\password.txt")

This file does not exist.

tip: do a Response.Write Server.MapPath(etc...), to see if the path to the file is correct.

You said that all pages as well as the password.txt file reside in the same directory.
In that case
Server.MapPath("password.txt") will give you the correct path

dondmcg
10-12-2003, 01:35 PM
Thanks I did that and now I am getting a message that says I need to use a virtual path?

Server.MapPath() error 'ASP 0172 : 80004005'

Invalid Path

/engine.asp, line 8

The Path parameter for the MapPath method must be a virtual path. A physical path was used.


What is the virtual path? How do I make sure I have the right one?

rdoekes
10-12-2003, 01:53 PM
I do not know the set up of your file system, so I cannot exactly tell you what to do. But here some pointers.
Say your web app is http://www.somedomain.com/webapp1 and is located on your file system in c:\somedir\webapp1

Then c:\somedir\webapp1 is the physical path, while /webapp1 is the virtual path to the webapplication.

Server.MapPath uses a virtual path to a specific file or folder and returns the physical path.

Hope this helps.

dondmcg
10-12-2003, 04:03 PM
Thanks very much rdoekes I hope to return a favor one day.

Dondmcg