Methexis
Methexis

Reputation: 2861

ASP Form to Text file

I have written some code from what I can gather from online sources to submit some text from a form into a text file, now I do not know what I am missing but nothing is coming through to the text file, I am guessing it might be something to do with maybe folder paths but I am not sure, just looking for some direction on this.

My ASP Form Code is:

<form method="get" action="simpleform.asp">

<br/>
<i>Please include your initials and date with the bug report</i> 
<br/>
<br/>
<b>Bug</b> <input type="text" name="bug">

<input type="submit" value="Submit Bug Report">
</form>
<br/>

ASP Code to comit the text to the file is this:

<html>
<body>
Thanks for the report! To report another bug <a href="BugReportPage.asp">click         here</a>.

<%
Dim idea

dim fs,f

set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.OpenTextFile("G:\General\EM_Wiki\WikiBug\bugreport.txt",8,true)

idea= Request.QueryString("bug")


f.WriteLine(bug)
f.Close
set f=nothing
set fs=nothing

%>
</body>
</html>

Hope that makes sense to someone and that you can point me in the right direction, thanks!

Upvotes: 0

Views: 837

Answers (2)

Tauseef
Tauseef

Reputation: 2052

your actual content is in variable idea, not in bug. bug is just an index of query string. Also you may need to flush your stream.

Use the flush method before closing file , e f.flush()

f.WriteLine(idea)
//your more writing
f.flush()
f.Close

here's the msdn link

http://msdn.microsoft.com/en-us/library/system.io.streamwriter.flush.aspx

Upvotes: 1

David
David

Reputation: 34563

You aren't writing the correct variable to the file.

f.WriteLine(bug) should be f.WriteLine(idea)

If you turn on "Option Explicit", it is easier to diagnose these kinds of problems. Here's the page that shows you how to do this: http://msdn.microsoft.com/en-us/library/ms524870(v=vs.90).aspx

Upvotes: 3

Related Questions