[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

Go Daddy web form using .asp to produce flat file?

How can I get a web form using GoDaddy's gdform.asp to produce a flat file that I can then import into a database? The form is working perfectly as far as it was designed to but it would save me hours of work if I could capture a days worth of emails into a single flat file. I had a script that worked wonderfully on a Unix  / linux  hosted site but this new site is hosted on a windows machine and requires .asp so I'm completely lost as to how to set this up. My requirements are a flat file (.csv or .txt) that is updated each time a form is submitted and preferably something that creates a new file everyday with a filename representing the date created. Does anyone know of a script like this that is compatible with a windows hosted GoDaddy account or is it simple enough to modify gdform.asp?
0
ezucker
Asked:
ezucker
  • 4
  • 3
1 Solution
 
L00MCommented:
I (and I sure many others) am not familiar with gdform.asp. If it's not very large, can you post the source here? You should be able to modify it to use FSO to create a daily file, then append to it throughout the day.
If the file is really big, upload it to EE Stuff and let us know the link.

http://www.ee-stuff.com/
0
 
ezuckerAuthor Commented:
This is the gdform.asp file, it appears to already be using FSO to create a file that go daddy then emails off to me. I've found the folder and file on my web server after a form is submitted but this file is deleted after the email is sent and the format is not something I could import. I'm not familiar with FSO or much by way of ASP so I'm not sure how i could make this work how i want it to. Thanks for the quick response!

<%

Dim landing_page, host_url
Dim fso, outfile, filename, dirname, myFolder
Dim req_method, key, value
Dim bErr, errStr, bEmpty
On Error resume next
bErr = false
bEmpty = true
errStr = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")
dtNow = Now()
filename = Server.MapPath("\ssfm")
dirname = filename
filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)

Function FormatVariableLine(byval var_name, byVal var_value)
      Dim tmpStr
      tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
      tmpStr = tmpStr & var_value & vbCRLF
      tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
      FormatVariableLine = tmpStr
end function

Sub OutputLine(byVal line)
   outfile.WriteLine(line)
end sub

if err.number = 0 then
      Set outfile = fso.CreateTextFile(filename, true, false)
      if err.number <> 0 then
                  bErr = true
                  errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
      else
            if(req_method = "GET") then
                  for each Item in request.QueryString
                        if item <> "" then
                              bEmpty = false
                              key = item
                              value = Request.QueryString(item)
                              if(lcase(key) = "redirect") then
                                    landing_page = value
                              else
                                    line = FormatVariableLine(key, value)
                                    Call OutputLine(line)
                              end if
                        end if      
                  next
            elseif (req_method = "POST") then
                  for each Item in request.form
                        if item <> "" then
                              bEmpty = false
                              key = item
                              value = Request.form(item)
                              if(lcase(key) = "redirect") then
                                    landing_page = value
                              else
                                    line = FormatVariableLine(key, value)
                                    Call OutputLine(line)
                              end if
                        end if      
                  next
            end if
            outfile.close
      end if      
      if(bEmpty = true) AND errStr = "" then
            bErr = true
            errStr = errStr & "<br>No variables sent to form! Unable to process request."
      end if
      if(bErr = false) then      
            if (landing_page <> "") then
                  response.Redirect "http://" & host_url & "/" & landing_page
            else
                  response.Redirect "http://" & host_url      
            end if
      else
            Response.Write errStr
      end if      
      set fso = nothing
else
  Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
end if
%>
0
 
L00MCommented:
Nothing in that script actually deletes the file. It seems this script is only for creating the file. After this script runs, another script or procedure is somehow picking up that file and consuming it. No matter, we aren't concerned about that file, instead, we want to create a file of our own. While I get that code together, can you tell me, did you still want to receive the emails? Or do you just want to modify this script to generate a text file of the submitted results?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ezuckerAuthor Commented:
Yes, I still need to receive the e-mails, if only as a backup to verify that the information is being correctly imported into our database.
0
 
L00MCommented:
Ok, I've modified the script. I recommend you change the path for 'myFileName' as desired. Also, I've not tested this script, although I'm confident it will work as is, or with little modification. Try it and let me know:

<%
Dim landing_page, host_url
Dim fso, outfile, filename, dirname, myFolder
Dim req_method, key, value
Dim bErr, errStr, bEmpty

' Added -------------------
Dim myFileName, myFSO, myOutFile, ForReading, ForWriting, ForAppending
Const ForReading   = 1
Const ForWriting   = 2
Const ForAppending = 8
' -------------------------

On Error resume next
bErr = false
bEmpty = true
errStr = ""
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set myFSO = Server.CreateObject("Scripting.FileSystemObject")

host_url = Request.ServerVariables("HTTP_HOST")
req_method = Request.ServerVariables("REQUEST_METHOD")
dtNow = Now()
filename = Server.MapPath("\ssfm")
dirname = filename
filename = filename & "\gdform_" & DatePart("M", dtNow) & DatePart("D", dtNow) & DatePart("YYYY", dtNow) & DatePart("N", dtNow) & DatePart("S", dtNow)

' Added -------------------
myFileName = Server.MapPath(".") ' You may want to modify this to point to a subdirectory of your choice.
myFileName = myFileName & "\" & Day(Now()) & Month(Now()) & Year(Now()) & "_formvals.txt"
' -------------------------

Function FormatVariableLine(byval var_name, byVal var_value)
      Dim tmpStr
      tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " START>" & vbCRLF
      tmpStr = tmpStr & var_value & vbCRLF
      tmpStr = tmpStr & "<GDFORM_VARIABLE NAME=" & var_name & " END>"
      FormatVariableLine = tmpStr
end function

Sub OutputLine(byVal line)
   outfile.WriteLine(line)
   ' Added -------------------
   myOutFile.WriteLine(line)
   ' -------------------------
end sub

if err.number = 0 Then
      ' Added -------------------
           If Not myFSO.FileExists(myFileName) Then
              myOutFile = myFSO.CreateTextFile(filename, true, false)
        Else
              myOutFile = myFSO.OpenTextFile(myFileName, ForAppending, true)
        End If
      ' -------------------------

      Set outfile = fso.CreateTextFile(filename, true, false)
      if err.number <> 0 then
                  bErr = true
                  errStr = "Error creating file! Directory may not be writable or may not exist.<br>Unable to process request."
      else
            if(req_method = "GET") then
                  for each Item in request.QueryString
                        if item <> "" then
                              bEmpty = false
                              key = item
                              value = Request.QueryString(item)
                              if(lcase(key) = "redirect") then
                                    landing_page = value
                              else
                                    line = FormatVariableLine(key, value)
                                    Call OutputLine(line)
                              end if
                        end if      
                  next
            elseif (req_method = "POST") then
                  for each Item in request.form
                        if item <> "" then
                              bEmpty = false
                              key = item
                              value = Request.form(item)
                              if(lcase(key) = "redirect") then
                                    landing_page = value
                              else
                                    line = FormatVariableLine(key, value)
                                    Call OutputLine(line)
                              end if
                        end if      
                  next
            end if
            outfile.close
      end if      
      if(bEmpty = true) AND errStr = "" then
            bErr = true
            errStr = errStr & "<br>No variables sent to form! Unable to process request."
      end if
      if(bErr = false) then      
            if (landing_page <> "") then
                  response.Redirect "http://" & host_url & "/" & landing_page
            else
                  response.Redirect "http://" & host_url      
            end if
      else
            Response.Write errStr
      end if      
      set fso = nothing
else
  Response.Write " An Error Occurred creating mail message. Unable to process form request at this time."
end if


%>
0
 
ezuckerAuthor Commented:
When running this script I get the error below, any thoughts? By the way, thank you so much for your time!

Microsoft VBScript compilation  error '800a0411'

Name redefined

/gdform.asp, line 10

Const ForReading   = 1
0
 
L00MCommented:
NP on the time. Glad to help.

Ah, very good! That means you probably have 'adovbs.inc' included somewhere. I'd just remark those three lines and the Dim statement as follows. (add a single quote at the front:)

' Added -------------------
Dim myFileName, myFSO, myOutFile ', ForReading, ForWriting, ForAppending
'Const ForReading   = 1
'Const ForWriting   = 2
'Const ForAppending = 8
' -------------------------
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now