unable to post info into access.
Hi I need a bit of help . i'm trying to post info into a access db from a form . but is not working here is the code.
(dbCREATED= "LEADS" tables= "SELLER".)
SELLERLEAD2.ASP
<html>
<head>
<link href="CSS/forms.css" rel="stylesheet" type="text/css">
</head>
<body>
<p>Seller Questionnaire page</p>
<form name="form" action="addtodb.asp" method="post">
<table border="0" align="center">
<tr>
<td><table width="100%" border="0" class="maintable">
<tr class="tableheader">
<td colspan="4"><strong>Contact Infomation </strong></td>
</tr>
<tr>
<td width="20%"><span class="asterisk">*</span>First Name </td>
<td width="21%"><input name="FirstName" type="text" class="Require" id="FirstName"></td>
<td width="15%"><span class="asterisk">*</span>Day Phone </td>
<td><input name="Dayphone" type="text" class="Require" id="Dayphone"></td>
</tr>
<tr>
<td><span class="asterisk">*</span>Last Name </td>
<td><input name="LastName" type="text" class="Require" id="LastName"></td>
<td><span class="asterisk">*</span>Evening Phone </td>
<td><input name="Eveningphone" type="text" class="Require" id="Eveningphone"></td>
</tr>
<tr>
<td><span class="asterisk">*</span>Email</td>
<td><input name="Email" type="text" class="Require" id="Email"></td>
<td>Cell Phone </td>
<td><input name="Cellphone" type="text" class="Require" id="Cellphone"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><span class="asterisk">*</span>Best time to call? </td>
<td><select name="BTC" class="Require" id="BTC">
<option value="0" selected>-Select One-</option>
<option value="Anytime">Anytime</option>
<option value="Morning">Morning</option>
<option value="Afternoon">Afternoon</option>
<option value="Evening">Evening</option>
<option value="Night">Night</option>
</select></td>
</tr>
</table> <table width="100%" border="0" class="maintable">
<tr class="tableheader">
<td colspan="2"><strong>The Situation </strong></td>
</tr>
<tr>
<td width="32%"><span class="asterisk">*</span>Do you need to sell your house fast? </td>
<td width="68%"><input name="Sell_fast" type="radio" value="Yes">
Yes
<input name="Sell_fast" type="radio" value="No">
No</td>
</tr>
<tr>
<td colspan="2"><input name="Submit" type="submit" class="submit" value="Submit Now"></td>
</tr>
</table> </td>
</tr>
</table>
</form>
<p> </p>
</body>
</html>
then here is my addtodb.asp page
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'declare your variables
Dim First Name, Last Name,Email, Day phone, Evening phone, BTC, Sellfast
Dim sConnString, connection, sSQL
' Receiving values from Form, assign the values entered to variables
First Name = Request.Form("FirstName")
Last Name = Request.Form("LastName")
Email = Request.Form("Email")
Day phone = Request.Form("Dayphone")
Evening phone = Request.Form("Eveningphone")
BTC = Request.Form("BTC")
Sellfast = Request.Form("Sell_fast")
'declare SQL statement that will query the database
sSQL = "INSERT into SELLER (First Name, Last Name, Email, Day phone, Evening phone, BTC,Sellfast) values ('" &FirstName & "', '" & LastName & "', '" & Email & "','"& Dayphone & "', '" & Eveningphone & "','" & BTC & "','" & Sell_fast & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Server.MapPath("/LEADS.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
%>
</body>
</html>
please feel free to email me or rewrite the code or anything. thanks.
Give a fish to the man and he will eat for a day;Teach him how to fish and he will eat for life.
|