ASP Code
  Home arrow ASP Code arrow Free input form all done from one Page usi...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

Free input form all done from one Page using Sub Procedures
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 3
    1999-10-11

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


     

    <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%">&nbsp;</td>
    </tr>
    <tr>
    <td colspan="2" width="100%"><textarea rows="6" name="comments" cols="58"></textarea></td>
    </tr>
    </table>
    <p>&nbsp;</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

     

    IBM® developerWorks developerWorks - FREE Tools!


    IBM DB2 Deep Compression ROI Tool

    The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times.
    FREE! Go There Now!


    NEW! IBM – Taking Web 2.0 to Work

    David Barnes, Lead Evangelist for IBM Emerging Internet Technologies 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!


    NEW! A Layered approach to delivering security-rich Web applications

    As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper.
    FREE! Go There Now!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer.
    FREE! Go There Now!


    NEW! Best Practices in Integrated Requirements Management

    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!


    NEW! Don't wait! Try the Rational Application Developer (RAD) v7.5 open beta code today

    Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems.
    FREE! Go There Now!


    NEW! The role of integrated requirements management in software delivery

    This paper is about the critical role that a discipline called integrated require­ments management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrat­ing, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way.
    FREE! Go There Now!


    NEW! Trial download: IBM Lotus Forms V3.0

    Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format.
    FREE! Go There Now!


    NEW! Webcast: What is new in Viper 2 for developers?

    Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications.
    FREE! Go There Now!


    NEW! Whitepaper: Delivering SOA solutions: service lifecycle management

    The unprecedented scope of a service-oriented architecture (SOA) initiative brings to the forefront a number of management and governance issues that were sidestepped in the past. The key to a successful SOA implementation is managing and governing activities throughout the entire SOA delivery lifecycle by ensuring that services conform to the needs of all of the business’s stakeholders. Learn how service lifecycle management allows the business to ensure that the process by which services are defined, created, tested, deployed, optimized and retired is manageable, repeatable and auditable.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek