Here's my code for a sample ASP guestbook I'm messing with. I doing this from a free website that lets you have server side files including .asp. I'm doing this from the site since I have Windows XP home which doesn't support PWS!!!! I have this inside the cgi_bin and the root folder is where my default page links to this page. The page comes up, I input the info, then when I submit it says "Thanks for your entry (name user used goes here)." But there is an error saying "Microsoft VBScript runtime error '800a0046' Permission denied" Says error on line 54
I have a blank guestbook.txt in the same directory(cgi_bin). O.k. here's the code:
<% @LANGUAGE = VBScript %>
<% ' Fig. 25.12 : guestbook.asp
' Demonstrating File System Objects
Option Explicit
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
<html xmlns = "
<head>
<title>GuestBook Example</title>
<style type = "text/css">
hr { size: 1; color: blue }
table { text-align: center }
td { font-size: 12pt }
p { font-size: 14pt; color: blue }
.font { font-family: arial, sans-serif }
</style>
</head>
<body>
<%
Dim fileObject, textFile, guestBook, mailtoUrl
' get physical path for this ASP page and
' concatenate guestbook.txt to it
guestbook = Request.ServerVariables( "APPL_PHYSICAL_PATH" ) _
& "guestbook.txt"
' instantiate a FileSystemObject
Set fileObject = Server.CreateObject( _
"Scripting.FileSystemObject" )
' check if this request is after the user has posted the form
If Request( "hiddenInput" ) = "true" Then
' print a thank you
Call Response.Write( "Thanks for your entry, " & _
Request( "username" ) & "!" )
%>
<hr />
<%
' build the mailtoUrl
mailtoUrl = Date() & " <a href = " & Chr( 34 ) _
& "mailto:" & Request( "email" ) & Chr( 34 ) _
& ">" & Request( "username" ) & "</a>: "
' open the guestbook, 8 is for appending
' create the guestbook if it does not exist
Set textFile = _
fileObject.OpenTextFile( guestbook, 8, True )
' write data to guestbook.txt
Call textFile.WriteLine( "<hr />" & mailtoUrl & _
Request( "comment" ) )
Call textFile.Close()
End If
%>
<p>Please leave a message in our guestbook.</p>
<!-- write form to the client -->
<form action = "guestbook.asp" method = "post">
<table>
<tr>
<td>Your Name: </td>
<td><input class = "font"
type = "text" size = "60"
name = "username" /></td>
</tr>
<tr>
<td>Your email address:</td>
<td><input class = "font"
type = "text" size = "60"
name = "email"
value = "user@isp.com" />
</td>
</tr>
<tr>
<td>Tell the world: </td>
<td><textarea name = "comment" rows = "3"
cols = "50">
Replace this text with the information
you would like to post.</textarea></td>
</tr>
</table>
<input type = "submit" value = "submit" />
<input type = "reset" value = "clear" />
<input type = "hidden" name = "hiddenInput"
value = "true" />
</form>
<%
' check if the file exists
If fileObject.FileExists( guestBook ) = True Then
' open the guestbook, "1" is for reading
Set textFile = fileObject.OpenTextFile( guestbook, 1 )
' read the entries from the file and write them to
' the client.
Call Response.Write( "Guestbook Entries:<br />" & _
textFile.ReadAll() )
Call textFile.Close()
End If
%>
</body>
</html>
If anyone can help I'd appreciate it.
I have a blank guestbook.txt in the same directory(cgi_bin). O.k. here's the code:
<% @LANGUAGE = VBScript %>
<% ' Fig. 25.12 : guestbook.asp
' Demonstrating File System Objects
Option Explicit
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
<html xmlns = "
<head>
<title>GuestBook Example</title>
<style type = "text/css">
hr { size: 1; color: blue }
table { text-align: center }
td { font-size: 12pt }
p { font-size: 14pt; color: blue }
.font { font-family: arial, sans-serif }
</style>
</head>
<body>
<%
Dim fileObject, textFile, guestBook, mailtoUrl
' get physical path for this ASP page and
' concatenate guestbook.txt to it
guestbook = Request.ServerVariables( "APPL_PHYSICAL_PATH" ) _
& "guestbook.txt"
' instantiate a FileSystemObject
Set fileObject = Server.CreateObject( _
"Scripting.FileSystemObject" )
' check if this request is after the user has posted the form
If Request( "hiddenInput" ) = "true" Then
' print a thank you
Call Response.Write( "Thanks for your entry, " & _
Request( "username" ) & "!" )
%>
<hr />
<%
' build the mailtoUrl
mailtoUrl = Date() & " <a href = " & Chr( 34 ) _
& "mailto:" & Request( "email" ) & Chr( 34 ) _
& ">" & Request( "username" ) & "</a>: "
' open the guestbook, 8 is for appending
' create the guestbook if it does not exist
Set textFile = _
fileObject.OpenTextFile( guestbook, 8, True )
' write data to guestbook.txt
Call textFile.WriteLine( "<hr />" & mailtoUrl & _
Request( "comment" ) )
Call textFile.Close()
End If
%>
<p>Please leave a message in our guestbook.</p>
<!-- write form to the client -->
<form action = "guestbook.asp" method = "post">
<table>
<tr>
<td>Your Name: </td>
<td><input class = "font"
type = "text" size = "60"
name = "username" /></td>
</tr>
<tr>
<td>Your email address:</td>
<td><input class = "font"
type = "text" size = "60"
name = "email"
value = "user@isp.com" />
</td>
</tr>
<tr>
<td>Tell the world: </td>
<td><textarea name = "comment" rows = "3"
cols = "50">
Replace this text with the information
you would like to post.</textarea></td>
</tr>
</table>
<input type = "submit" value = "submit" />
<input type = "reset" value = "clear" />
<input type = "hidden" name = "hiddenInput"
value = "true" />
</form>
<%
' check if the file exists
If fileObject.FileExists( guestBook ) = True Then
' open the guestbook, "1" is for reading
Set textFile = fileObject.OpenTextFile( guestbook, 1 )
' read the entries from the file and write them to
' the client.
Call Response.Write( "Guestbook Entries:<br />" & _
textFile.ReadAll() )
Call textFile.Close()
End If
%>
</body>
</html>
If anyone can help I'd appreciate it.