faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems : forms and user input

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 18 people (83%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

I'm searching an example of submitting a form to itself to do a DB update?

Jul 17th, 2000 05:05
unknown unknown, Keith Willis


Use this for an example...
<%@ language=vbscript %>
<%
    'check to see if the form was submitted.
    if Request("chkr") <> "" then
       'put some checking in here to make sure you have what you want.
       strSQL = "Put your SQL Here With all of your parameters"
       set conn = server.createobject("ADODB.Connection")
           conn.open  Dsn=yourDSN,username,password
       set rs = conn.execute(strSQL)
       response.redirect "thankyou.htm"
    end if
%>
<html>
   <head>
   <\head>
   <body>
        <form action=thispage.asp method=post>
            <input type=hidden name=chkr id=chkr value=1>
            <!--  Put your other form stuff here  -->
            <input type=submit value=submit name=mysubmit id=mysubmit>
        </form>
   </body>
</html>
The basis behind this is simple.  The chkr hidden field is going to 
contain a value only after the form has been submitted.  So if you first 
load the page, the chkr value has not been submitted so it is empty 
resulting in the server script not being executed inside of the if 
statement.



© 1999-2004 Synop Pty Ltd