<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! |
You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve. FREE! Go There Now!
|
|
|
|
Building a software-as-a-service solution requires addressing a few key technical challenges. In this webcast, we'll focus on the role of IBM Tivoli Directory Server and WebSphere Portlet Factory in creating a Software as a Service solution. We will demonstrate how to use Tivoli Directory Server to prevent the user population of one tenant from accessing the virtual portal and portlet components of another tenant. We will also use the dynamic profile capability of WebSphere Portlet Factory to create multiple highly customized applications from one code base. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to download IBM DB2 Express-C 9.5, a no-charge version of DB2 Express 9 database server. DB2 Express-C offers the same core data server base features as other DB2 Express editions and provides a solid base to build and deploy applications developed using C/C++, Java, .NET, PHP, and other programming languages. FREE! Go There Now!
|
|
|
|
Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization. FREE! Go There Now!
|
|
|
|
Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today. 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!
|
|
|
|
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!
|
|
|
|
Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes. 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!
|
|
|
|
The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |