|
<%
' IMPORTANT: The only difference between regular, chat, and bb pform code is the function call to DoProblemForm() below ****
Response.Write(vbcrlf & "" & vbcrlf)
' globals (i.e. script scope)
Dim status, firstname, lastname, email, browser, http_user_agent, os, ram, site, description, reproducible
Dim sJSK_Font1
sJSK_Font1 = ""
DoProblemForm("") ' regular problem form
'DoProblemForm("Chat") ' chat problem form
'DoProblemForm("Bulletin Board") ' bb problem form
Response.Write(vbcrlf & "" & vbcrlf)
%>
<%
Private Function DoProblemForm(sDescription)
DoProblemForm = TRUE ' always returns TRUE
Dim sDSN, sDbTable
Dim sBullet, assoc_array
Dim ErrorFlag, ErrorString, key, array_size, i
Dim DBConn, time_entered, my_insert
If sDescription = "Chat" Then
sDSN = "DSN=bChatSiteProblems; UID=bChatSiteProblems; PWD=ju1iusSK; DATABASE=SITE_PROBLEMS"
sDbTable = "CHAT_SITE_PROBLEMS"
ElseIf sDescription = "Bulletin Board" Then
sDSN = "DSN=bBBSiteProblems; UID=bBBSiteProblems; PWD=ju1iusSK; DATABASE=SITE_PROBLEMS"
sDbTable = "BB_SITE_PROBLEMS"
Else
sDSN = "DSN=bSiteProblems; UID=bSiteProblems; PWD=ju1iusSK; DATABASE=SITE_PROBLEMS"
sDbTable = "SITE_PROBLEMS"
End If
sBullet = ""
status = Request.Form("STATUS") ' Do not change this line !!!!
Set assoc_array = CreateObject("Scripting.Dictionary")
' ********* Modify below as needed *********
firstname = Request.Form("FIRST_NAME")
lastname = Request.Form("LAST_NAME")
email = Request.Form("EMAIL")
browser = Request.Form("BROWSER REQUIRED")
http_user_agent = Request.Form("HTTP_USER_AGENT")
os = Request.Form("OS REQUIRED")
ram = Request.Form("RAM")
site = Request.Form("SITE")
description = Request.Form("DESCRIPTION REQUIRED")
reproducible = Request.Form("REPRODUCIBLE")
' ********* Modify below as needed *********
' NOTE: "assoc_array" needed for display of missed REQUIRED fields
assoc_array.Add "BROWSER REQUIRED", "Browser/Version"
assoc_array.Add "OS REQUIRED", "Operating System"
assoc_array.Add "DESCRIPTION REQUIRED", "The " & sDescription & " Problem"
If status <> "processform" Then ' Show the form
ShowProblemForm(sDescription)
Else ' Process the form
ErrorFlag = FALSE
array_size = 0
ErrorString = sJSK_Font1 & "The following required fields must be submitted. Please try again." & ""
For Each key in Request.Form 'Cycle through values
If InStr(key, "REQUIRED") Then
If Trim(Request.Form(key)) = "" Then
ErrorFlag = TRUE
Redim Preserve missing_required_fields_array(array_size)
missing_required_fields_array(array_size) = assoc_array(key)
array_size = array_size + 1
End If
End If
Next
If ErrorFlag Then
Response.Write("
" & vbcrlf & "| " & ErrorString & " | " & vbcrlf)
if array_size > 0 then
For i = array_size - 1 to 0 Step -1
Response.Write("| " & sJSK_Font1 & sBullet & missing_required_fields_array(i) & "" & " | " & vbcrlf)
Next
End If
Response.Write(" " & vbcrlf)
ShowProblemForm(sDescription)
Else ' Send the form and do SQL back end stuff
On Error Resume Next
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open sDSN
time_entered = Now
' Replace ' with '' so SQL doesn't choke
firstname = Replace(firstname, "'", "''")
lastname = Replace(lastname, "'", "''")
email = Replace(email, "'", "''")
browser = Replace(browser, "'", "''")
os = Replace(os, "'", "''")
ram = Replace(ram, "'", "''")
site = Replace(site, "'", "''")
description = Replace(description, "'", "''")
reproducible = Replace(reproducible, "'", "''")
time_entered = Replace(time_entered, "'", "''")
http_user_agent = Replace(http_user_agent, "'", "''")
my_insert = "INSERT INTO " & sDbTable & " (First_Name, Last_Name, Email, Browser, OS, RAM, Site, Description, Reproducible, Time_Entered, Http_User_Agent) VALUES('" & firstname & "','" & lastname & "','" & email & "','" & browser & "','" & os & "','" & ram & "','" & site & "','" & description & "','" & reproducible & "','" & time_entered & "','" & http_user_agent & "')"
DBConn.Execute(my_insert)
If Err Then
Response.Write(sJSK_Font1 & "Sorry, there was a problem with the database. Please try again later. Choose one of the links above to go to another part of About.com. " & "")
Err.Clear
Else
Response.Write(sJSK_Font1 & " Thank you. Your information was successfully submitted." & "")
End If
DBConn.Close
End If
End If
End Function
%>
<% Private Function ShowProblemForm(sDescription) %>
<% ShowProblemForm = TRUE %>
<% Dim bc %>
<% End Function %>
|