Add form components to a database

This is a discussion on "Add form components to a database" within the Classic ASP section. This forum, and the thread "Add form components to a database are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Aug 18th, 2007, 17:04
Junior Member
Join Date: Jun 2007
Location: Arkansas
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Add form components to a database

First off, I will tell you that it has been over a year since I have messed with ACCESS and ASP code at college.

Here is my form page
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>
<body>

<H1>Contact Information</H1>

<FORM NAME="ContactForm" METHOD="POST" ACTION="add2db.asp">

Name:<INPUT NAME="Name" size="45"> <BR>
Address 1: <INPUT NAME="Adr1" size="45"> <BR>
Address 2:<INPUT NAME="Adr2" size="45"> <BR>
City: <INPUT NAME="City" size="18">  State:<INPUT NAME="State" size="2"> Zip Code: <INPUT NAME="Zip" size="5" type="int"><BR>
Email:<INPUT NAME="Email" size="51"><BR>
Phone1:<INPUT NAME="Phone1" size="51"><BR>
Phone2:<INPUT NAME="Phone2" size="51"><BR>
Phone3:<INPUT NAME="Phone3" size="51"><BR>

<H3>What is the nature of your project?</H3>

<INPUT TYPE="radio" NAME="PlanType" VALUE="Religious"> Religious ---> <SELECT NAME="Plans" SIZE="1"><OPTION SELECTED>Worship Centers<OPTION>Youth Centers<OPTION>Multi-Purpose</SELECT><BR>
<INPUT TYPE="radio" NAME="PlanType" VALUE="Educational"> Educational <BR>
<INPUT TYPE="radio" NAME="PlanType" VALUE="Residential"> Residential <BR>
<INPUT TYPE="radio" NAME="PlanType" VALUE="Commercial"> Commercial <BR>

If Religious - Seating Capacity? <input name="Seating" type=int size="5"> <BR>
<H3>Any more information?</H3><BR>
<textarea name="Other" cols=48 rows=4></textarea><BR>

<P>

<INPUT TYPE=SUBMIT> <INPUT TYPE=RESET>
</FORM>

</body>
</html>
Here is my ASP code:
Code: Select all
<%@ Language="VBScript" %>
<% Option Explicit %>
<html>
<head>
<title>Form to database</title>
</head>
<body>
<%
'declare your variables
Dim Name, Adr1, Adr2, City, State, Zip, Email, Phone1, Phone2, Phone3, PlanType, Plans, Seating, Other
Dim sConnString, connection, sSQL
'Receiving values from Contact, assign the values entered to variables
Name = Request.Form("Name")
Adr1 = Request.Form("Adr1")
Adr2 = Request.Form("Adr2")
City = Request.Form("City")
State = Request.Form("State")
Zip = Request.Form("Zip")
Email = Request.Form("Email")
Phone1 = Request.Form("Phone1")
Phone2 = Request.Form("Phone2")
Phone3 = Request.Form("Phone3")
PlanType = Request.Form("PlanType")
Plans = Request.Form("Plans")
Seating = Request.Form("Seating")
Other = Request.Form("Other")

'declare SQL statement that will query the database
sSQL = "INSERT into ContactInfo (Name, Adr1, Adr2, City, State, Zip, Email, Phone1, Phone2, Phone3, PlanType, Plans, Seating, Other, ) values ('" & Name & "','" & Adr1 & "','" & Adr2 & "','" & City & "','" & State & "','" & Zip & "', '" & Email & "','" & Phone1 & "','" & Phone2 & "','" & Phone3 & "','" & PlanType & "','" & Plans & "','" & Seating & "', '" & Other & "')"
'define the connection string, specify database
'driver and the location of database
sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source="ELRContact.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>
I have created a database in ACCESS with all of the components, Name, Phone1, Email, PlanType, etc... My problem is this. It doesn't work. I fill in all of the blanks, click SUBMIT, and it puts me over to add2db.asp. The page puts the entire asp code on the screen, and does not update the database.

All of these files are in the same folder. The database is called ELRContact.mdb with one table called ContactInfo. I am simply wanting information to enter the database.

I have tried accessing this through Opera browser, as well as IE, but it doesnt work. I seemt o be missing somethign, but I am not sure what. Any help would be greatly appreciated.

GW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Aug 18th, 2007, 17:09
JustinStudios's Avatar
Reputable Member
Join Date: Mar 2007
Location: USA
Posts: 404
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Add form components to a database

Sounds to me if its posting the code that your running this on a server that doesn't support ASP. I'd check that out first as that is usually the case. Also it's a great idea to instal IIS (if you have XP Pro) or another ASP server on your local machine to test there first to ensure that its not your code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Aug 18th, 2007, 17:17
Junior Member
Join Date: Jun 2007
Location: Arkansas
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Add form components to a database

Yes, well. I haven't actually uploaded it yet, you see. I was running this file locally to make sure that it added the information to the database before I made it live.

I may try this a different way, via php or some other such. I really don't want to start installing all sorts of sundry files on my computer. If it will not simply add form inputs into a database for me, it won't do it for anyone else either.

I remember doinging something like this at ITT, but it's been so long, I am at a complete and total loss.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
form database add

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP form to check weather a form value is already in the database Andrew1986 Classic ASP 3 Oct 25th, 2007 08:23
form database Barbs7349 Starting Out 1 Aug 12th, 2007 13:22
Add/Delete/Modify Database Record form David Blake Starting Out 6 May 1st, 2007 16:22
Submitting Web form results to a database theproman23 Databases 2 Jun 30th, 2005 13:21
insert form to database Monie Databases 1 Aug 25th, 2004 02:59


All times are GMT. The time now is 15:37.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42