G
Geoff Wickens
I am quite new to all this but am trying to create a database driven site. I
have been able to use information from my sample database but I now want to
be able to insert data into it. At present I put the data into my local copy
of the access database and then upload it again to my server - not an ideal
solution!
I have tried using the INSERT command and it works fine if I enter the data
into the statement. What I really want to do is collect the data from a form
and then insert this into the database. My code is as follows:
Page for collecting the data:
<form name="useradd" method="post" action="testadd.asp">
<p>Username:
<input type="text" name="username">
</p>
<p>Password:
<input type="text" name="password">
</p>
<p> Category:
<select name="select">
<option>member</option>
<option>committee</option>
<option>admin</option>
<option>guest</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
I then have the following code on the page (testadd.asp) to add this
information to my database.
<%
u = Request.Form("username")
p = Request.Form("password")
c = Request.Form("category")
Set Catalog=Server.CreateObject("ADODB.Recordset")
Catalog.open "INSERT INTO tbltest (username, password, category) VALUES (u ,
p, c)", "DSN=members"
%>
The thing which goes wrong is the VALUES part of the statement. It seems to
want 'u' etc but then puts in this text rather than the contents of my
variable.
Any help most welcome.
Geoff Wickens
have been able to use information from my sample database but I now want to
be able to insert data into it. At present I put the data into my local copy
of the access database and then upload it again to my server - not an ideal
solution!
I have tried using the INSERT command and it works fine if I enter the data
into the statement. What I really want to do is collect the data from a form
and then insert this into the database. My code is as follows:
Page for collecting the data:
<form name="useradd" method="post" action="testadd.asp">
<p>Username:
<input type="text" name="username">
</p>
<p>Password:
<input type="text" name="password">
</p>
<p> Category:
<select name="select">
<option>member</option>
<option>committee</option>
<option>admin</option>
<option>guest</option>
</select>
</p>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</p>
</form>
I then have the following code on the page (testadd.asp) to add this
information to my database.
<%
u = Request.Form("username")
p = Request.Form("password")
c = Request.Form("category")
Set Catalog=Server.CreateObject("ADODB.Recordset")
Catalog.open "INSERT INTO tbltest (username, password, category) VALUES (u ,
p, c)", "DSN=members"
%>
The thing which goes wrong is the VALUES part of the statement. It seems to
want 'u' etc but then puts in this text rather than the contents of my
variable.
Any help most welcome.
Geoff Wickens