Results 1 to 2 of 2

Thread: Saving Form to CSV

  1. #1
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Saving Form to CSV

    I have created a simple Form (Name, Address, Age, email address) in dreamweaver cs3 which uses ASP to show the results on a separate page.

    What I am after is a simple script that will allow me to save the results of the form to a txt or csv file. I am happy to have separate files for each entry but woudl prefer them to be added to the same file.

    Hoping someone could help here and hold my hand through it thanks - assuming it needs a script

  2. #2
    Join Date
    Feb 2011
    Posts
    16
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    this should get you started [untested]


    Code:
    <%
    dim oFSO, oFile
    dim strOutput
    
    set oFSO = server.createobject ("scripting.filesystemobject")
    set oFile = oFSO.createtextfile("D:\websites\" & FileName,true)
    for x = 1 to request.form.count()
            strOutput = strOutput & trim(request.form.item(x)) & ","
    
           'remove the last comma from the line before continuing
           strOutput = left(strOutput,len(strOutput)-1)
           oFile.writeline strOutput
       
    next
    
    oFile.close
    set oFile = nothing
    set oFSO = nothing
    
    %>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •