Lunarpages Web Hosting Forum

Author Topic: Writing data from registration Form into Access database  (Read 17081 times)

Offline nubileras

  • Space Explorer
  • ***
  • Posts: 8
Writing data from registration Form into Access database
« on: October 15, 2009, 10:52:00 AM »
Hi all I am trying to insert data from a basic registration form into my access database using ASP VBscript and using Dreamweaver as my editor.  I have been at this for days with no joy.

I have reviewed many tutorials to get assistance with this as I am new to the whole web designing and ASP.  I must say I have gotten my database named elektst.mdb to connect within dreamweaver.

My last attempt at trying to enter data within the database was done creating a basic html form for the users to input there info and then have an asp page which holds the write coding and redirects to a registration success page.  However when I try out the html form with data entered and I hit submit  I keep getting 404 Error message.

I have since tried to ensure that the page is properly saved and in the correct folders both on my local and remote server and last I changed the database connection, when i changed the connection thou it then gave me the error HTTP500 Internal Server error.

Presently I am stuck and totally confused and would like if anyone can shed some light and support to me please.  I am attaching my coding for both the basic html form and the rgistration asp page.  Any help will be greatly appreciated.

Basic Html form page

 <form action="Registration%20success.asp" method="post" name="Member Registration">
    <input type="text" name="username" maxlength="20"> <br>
      Password: <input type="Password" name="password" maxlength="20"> <br>
      First Name: <input type="text" name="firstname" maxlenght="20"> <br>
      Last Name: <input type="text" name="lastname" maxlength="20"> <br>
      Email Address: <input type="text" name="emailaddress" maxlength="20"> <br>
    <input name="Sumbit" type="submit" value="Submit">

Coding for Registration ASP

<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

'Dimension variables
Dim adoCon  'Holds the database connection object
Dim rsAddCustomer  'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database

'Create an ADO connection object
set adoCon =Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection Object usine a DSN-less Connection
adoCon.Open "DRIVER=Microsoft Access Driver(*.mdb); Data Source=" & Server.MapPath("elektst.mdb")

'Create an ADO recordset object
Set rsAddCustomer = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statment to query the database
strSQL = "SELECT tblCustomer.Username, tblCustomer.Password, tblCustomer.First Name, tblCustomer.Last Name, tblCustomer.Email Address FROM tblCustomer;"

'Set the cursor type we are using so we can navigate through the recordset
rsAddCustomer.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsAddCustomer.LockType = 3

'Open the recordset with the SQL query
rsAddComments.Open strSQL, adoCon

'Tell the recordset we are adding a new record to it

'Add a new record to the recordset
rsAddCustomer.Fields("Username") = Request.Form("username")
rsAddCustomer.Fields("Password") = Request.Form("password")
rsAddCustomer.Fields("First Name") = Request.Form("firstname")
rsAddCustomer.Fields("Last Name") = Request.Form("lastname")
rsAddCustomer.Fields("Emailaddress") = Request.Form("emailaddress")

'Write the updated recordset to the database

'Reset Server objects
Set rsAddCustomer = Nothing
Set adoCon = Nothing

'Redirect to the Registration Success.asp page
Response.Redirect "guestbook.asp"