<h2>Please Enter contact information in the form below so we may contact you about advertising.</h2>
<table border="1" width="100%">
<tr>
<td width="18%">Name:</td>
<td width="82%"><input type="text" name="name" size="40"></td>
</tr>
<tr>
<td width="18%">Email Address:</td>
<td width="82%"><input type="text" name="emailaddress" size="40"></td>
</tr>
<tr>
<td width="18%">Phone Number:</td>
<td width="82%"><input type="text" name="phonenumber" size="40"></td>
</tr>
<tr>
<td width="18%">Comments</td>
<td width="82%"> </td>
</tr>
<tr>
<td colspan="2" width="100%"><textarea rows="6" name="comments" cols="58"></textarea></td>
</tr>
</table>
<p> </p>
<p><input type="submit" value="Submit" name="btnSubmit"><input type="reset" value="Reset"
name="B2"></p>
</form>
</BODY>
</html>
<% End Sub %>
3 of 3 subs that is used in this example This procedure does the server-side code to insert a record and send an email. Then it redirects back to the form with one request.querystring variable to notify the Thank you page to be displayed.
<% Sub DoRecords() %>
'Note that I'm using an include file for my connection string, sense all server-side processing that needs a database connection is inside this sub that is where I place the connection string. You could easily put a DSN Entry, DSN-Less entry in here too.
<!--#include file="conn.asp"-->
<%
dim strconn
dim conn
dim rs
set conn = server.createobject("adodb.connection")
conn.open strconn
set rs = server.createobject("adodb.recordset")
rs.open "PutYourTableNameHere", conn, 3, 3
rs.addnew
rs("name") = request("name")
rs("emailaddress") = request("emailaddress")
rs("phonenumber") = request("phonenumber")
rs("comments") = request("comments")
rs("DateSubmitted") = date()
rs.update
rs.close
set rs = nothing
conn.close
set conn = nothing
'Builds the body of the Message
strBody = "A request for some info about your site" & chr(10) & chr(10)
strBody = strBody & "Name: " & request("Name") & chr(10)
strBody = strBody & "EmailAddress: " & request("Emailaddress") & chr(10)
strBody = strBody & "PhoneNumber: " & request("PhoneNumber") & chr(10)
strBody = strBody & "Comments: " & chr(10) & request("comments")
'Mails a copy of this request to the someone
set objNewMail = server.CreateObject("CDONTS.NewMail")
objNewMail.From = "ASPFree.com"
objNewMail.To = "someone@aspfree.com"
objNewMail.BCC = "someone@aspfree.com"
objNewMail.Subject = "A Simple form to collect info"
objNewMail.Body = strBody
objNewMail.Send
set objNewMail = Nothing
response.redirect "ads.asp?strMessage=Thanks"
End Sub
%>
<%
This is where the real logic is done.
'This If statement displays the Intro Page
If request("btnSubmit") = "" and request("strMessage") = "" Then
call IntroPage()
End If
This if calls the DoRecords() Sub to process the form values
If request("btnSubmit") = "Submit" Then
call DoRecords()
End If
This if processes the Thank you page after the form was submitted
if request("strMessage") <> "" Then
call Thanks()
End If
%>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles
More By aspfree
developerWorks - FREE Tools! |
Learn field-tested SOA principles, methodology, technology and implementation from the global SOA market leader - in a new e-book by an IBM SOA expert. Written by IBM Certified SOA Solution Designer Bobby Woolf, "Exploring IBM SOA Technology & Practice" is the ultimate insider's guide to SOA - a PDF e-book packed cover to cover with IBM's specific advice on how to make your SOA implementation a success. FREE! Go There Now!
|
|
|
|
Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right." FREE! Go There Now!
|
|
|
|
Learn to enable users to both rate existing animations and to combine existing animations into new snippets. This is the third in a series of three tutorials that chronicle the building of a site that enables collaborative discussion and animation building using Domino and OpenLaszlo. FREE! Go There Now!
|
|
|
|
Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise. FREE! Go There Now!
|
|
|
|
Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
|
|
|
|
Ken Krugler, co-founder of code search company Krugle, and Laura Merling, vice president of Marketing and Business Development for Krugle, join to talk about the ins and outs of code search and what it means as a new feature for developerWorks users. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 4 at 1:00 pm ET to discuss how Rational Method Composer can help meet your compliance objectives. Get your questions answered! FREE! Go There Now!
|
|
|
|
Because access to government information continues to be an area of concern for many U.S. citizens with disabilities, the U.S. government enacted Section 508 of the Rehabilitation Act in 2001 to ensure that government agencies create accessible Web content, enabling all citizens to access the information they need. A fully accessible Web site makes Web content accessible to all individuals, including those with disabilities, who may be accessing Web content via a variety of user agents. Common user agents include standard Web browsers, text-only browsers, assistive devices and mobile devices such as cell phones or personal digital assistants (PDAs). FREE! Go There Now!
|
|
|
|
Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
|
|
|
|
In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |