Fejl i gæstebog!
Jeg har rodet lidt med en gæstebog, som desværre ikke helt fungerer! så derfor håber jeg i kan hjælpe mig...Gæstebogen skriver informationer til en fil
-------------------------------------------------------
guestbook.asp:
<% @LANGUAGE = VBScript %>
<% ' Demonstrating File System Objects
Option Explicit
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<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 bgcolor="#D9D9D9">
<center>
<%
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( "Tak for din kommentar, " & _
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>Læg venligst en kommentar i vores gæstebog</p>
<!-- write form to the client -->
<form action = "guestbook.asp" method = "post">
<table>
<tr>
<td>navn: </td>
<td><input class = "font"
type = "text" size = "60"
name = "username" /></td>
</tr>
<tr>
<td>e-mail adresse:</td>
<td><input class = "font"
type = "text" size = "60"
name = "email"/>
</td>
</tr>
<tr>
<td>Kommentar: </td>
<td><textarea name = "comment" rows = "3"
cols = "50"></textarea></td>
</tr>
</table>
<input type = "submit" value = "send" />
<input type = "reset" value = "slet" />
<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( "Kommentarer i gæstebogen:<br />" & _
textFile.ReadAll() )
Call textFile.Close()
End If
%>
</body>
</html>
-----------------------------------------------------------------
Jeg får følgende fejl fra serveren:
Technical Information (for support personnel)
Error Type:
Scripting.FileSystemObject.1 (0x80070005)
You are not permitted to access a file which is not located within your ASP application's root.
/guestbook/guestbook.asp, line 53
-----------------------------------------------------------------
nogen der har en løsning? jeg er desværre temmelig noob til ASP, så løsninger må gerne skæres ud i pap!
Mikael
