Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_database_setup thread: inputting data into a database


Message #1 by "Adam" <adam_hw@k...> on Mon, 11 Nov 2002 16:49:05
Hi

I have a form that I'm using to try and add data to my database.  I put 
the data in the required field and click next but nothing happens - the 
page just remains the same and doesnt' throw up any errors - however, it 
should move on to another page!

My code is below.

I'm pretty new to this stuff so the mistake will no doubt be obvious to 
the trained eye!

thanks in anticipation.

Adam

<%
strMode = Request.Form("pagemode")
If Len(Request("back")) Then
      strMode = strMode - 1
Else
      strMode = strMode + 1
End If
if Len(Request("Cancel")) > 0 then response.redirect "insert.asp"
if len(Request("finish")) > 0 then strMode = "4"
%>

<html>
      <head><title>Request for Information</title></head>
      <body>
            <h1>Request for Information</h1><hr>
      <br><form method="post"><br>
<% If strMode = "2" Then %>
      <center><h2>Contact Information</h2></center><hr>
      <br><br>
      Phone Number: <input type=text name="Phone_number" value="<% = 
Server.HTMLEncode(Request("phone_number")) %>"><br>
      E-Mail Address: <input type=text name="E_mail" value="<% = 
Server.HTMLEncode(Request("e_mail")) %>"><br>
      <input type=hidden name="first_name" value="<% = Server.HTMLEncode
(Request("first_name")) %>">
      <input type=hidden name="last_name" value="<% = Server.HTMLEncode
(Request("last_name")) %>">
      <input type=hidden name="comments" value="<% = Server.HTMLEncode
(Request("comments")) %>">
      <input type=hidden name="pagenum" value="3">
      <hr>
      <input type=submit name="back" value="&lt; &nbsp; Back"> &nbsp;
      <input type=submit name="next" value="Next &nbsp; &gt;"> &nbsp;
      <input type=submit name="cancel" value="Cancel">

<% ElseIf StrMode = "3" Then %>
      <center><h2>Information</h2></center><hr>
      <br><br>
      Please specify what you would like to know: <br>
      <textarea name="comments"><% = Server.HTMLEncode(Request
("comments")) %></textarea>
      <input type=hidden name="first_name" value="<% = Server.HTMLEncode
(Request("first_name")) %>">
      <input type=hidden name="last_name" value="<% = Server.HTMLEncode
(Request("last_name")) %>">
      <input type=hidden name="phone_number" value="<% = Server.HTMLEncode
(Request("phone_number")) %>">
      <input type=hidden name="e_mail" value="<% = Server.HTMLEncode
(Request("e_mail")) %>">
      <input type=hidden name="pagenum" value="3">
      <hr>
      <input type=submit name="back" value="&lt; &nbsp; Back"> &nbsp;
      <input type=submit name="finish" value="Finish &nbsp;"> &nbsp;
      <input type=submit name="cancel" value="Cancel">
<% ElseIf strMode="4" Then %>


<%

set con = server.createobject("ADODB.Connection")
con.open Application("adam_ConnectionString")

Dim mySQL

mySQL ="INSERT INTO adam ([first name], [last name], [phone number], 
email, comments) VALUES " & _
"('" & first_name & "','" & last_name & "','" & phone & "','" & email & _
"','" & comments & "')"

%>

<% Else %>
      <center><h2>Personal Information</h2></center><hr>
      <br><br>
      First Name: <input type=text name="first_name" value="<% = 
Server.HTMLEncode(Request("first_name")) %>"><br>
      Last Name: <input type=text name="last_name" value="<% = 
Server.HTMLEncode(Request("last_name")) %>"><br>
      <input type=hidden name="phone_number" value="<% = Server.HTMLEncode
(Request("phone_number")) %>">
      <input type=hidden name="e_mail" value="<% = Server.HTMLEncode
(Request("e_mail")) %>">
      <input type=hidden name="comments" value="<% = Server.HTMLEncode
(Request("comments")) %>">
      <input type=hidden name="pagenum" value="1">
      <hr>
      <input type=submit name="next" value="Next &nbsp; &gt;"> &nbsp;
      <input type=submit name="cancel" value="Cancel">
<% End If %>
    </form>
    </body>
</html>
Message #2 by huckkeon@t... on Tue, 12 Nov 2002 07:52:45
Adam,
try change this line 
<form method="post">
to
<form method="post"action="abc.asp">
where abc.asp is ur destination file name.

i'm also new to asp but hope this help.

rgds,
hk tan

  Return to Index