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 – Taking Web 2.0 to Work

    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!


    NEW! Addressing software-as-a-service challenges using Tivoli security and WebSphere solutions

    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!


    NEW! Download DB2 Express-C 9.5

    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!


    NEW! Download IBM WebSphere Portal V6.1 beta code

    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!


    NEW! Hacking 101

    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!


    NEW! Improve your build process with IBM Rational Build Forge, Part 1: Create a continuous build and integration environment

    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!


    NEW! Rational Talks to You: Manage RUP-based CMMI initiatives

    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!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    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!


    NEW! Webcast: Calling All Testers! Find Application Vulnerabilities Early in the Development Process Where they are Easier to Fix and Less Risky to your Business

    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!


    NEW! Webcast: Eclipse: Empowering the universal platform

    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!

    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 5 Hosted by Hostway
    Stay green...Green IT