I'm still learning ASP so please bare with me on this.
I'm trying to write a customer satifaction survey so I need to pass the survey results to an MS Database. The problem is that no user data is being written into the db. But blank records are being written. I'm not sure what went wrong here. Can someone provide some assistance with this? I assume it's an easy fix.
This is the HTML page with the form data:
HTML Code:<html> <head> <title>New Customer Survey </title> <script language="javascript"> <!-- function ClearForm() { document.surveyForm.q2.value= ""; } function ClearQ3() { document.surveyForm.q3.value= ""; } function ClearQ4() { document.surveyForm.q4.value= ""; } //--> </script> </head> <p align=center> <img src=images/banner.jpg></p> <form name=surveyForm meathod=POST action=getsurvey.asp> <table border=1 align=center> <tr> <td>1. Do you remember the Tech that you spoke to regarding your problem?</td> <td> <select> <option value="select">--Select Answer--</option> <option value="Yes">Yes</option> <option value="No">No</option> </select> </td> <tr> <td>2. Overall, how do you feel the Tech Support Representative handled your issue?</td> <td><input type=text name=q2 value="Enter a number 1-5" onfocus="ClearForm();"> </td> <tr> <td>3. Do you feel that your issue was acknowledged within timely manner?</td> <td><input type=text name=q3 value="Enter a number 1-5" onfocus="ClearQ3();"</td> <tr> <td>4. Do you feel that your issue was acknowledged within timely manner?</td> <td><input type=text name=q4 value="Enter a number 1-5" onfocus="ClearQ4();"</td> </tr> </table> <br> <p align=center><input type=Submit value="Submit Survey"></p> </form>
Here is the ASP page that processes the form:
Code ASP:<%@ Language="VBScript" %> <% Option Explicit %> <html> <head> <title>Form to database</title> </head> <body> <% 'declare your variables Dim ques2, ques3, ques4 Dim sConnString, connection, sSQL 'Receiving values from Form, assign the values entered to variables ques2 = Request.Form("q2") ques3 = Request.Form("q3") ques4 = Request.Form("q4") 'declare SQL statement that will query the database sSQL = "INSERT into survey (Question2, Question3, Question4) values ('" & _ ques2 & "', '" & ques3 & "', '" & ques4 & "')" 'define the connection string, specify database 'driver and the location of database sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & Server.MapPath("data/survey.mdb") 'create an ADO connection object Set connection = Server.CreateObject("ADODB.Connection") 'Open the connection to the database connection.Open(sConnString) 'execute the SQL connection.execute(sSQL) response.write "The form information was inserted successfully." 'Done. Close the connection object connection.Close Set connection = Nothing


Reply With Quote

Bookmarks