ColdFusion Form Handling Michael Smith, President TeraTech, Inc

Slides:



Advertisements
Similar presentations
PHP Form and File Handling
Advertisements

23-Aug-14 HTML/XHTML Forms. 2 What are forms? is just another kind of XHTML/HTML tag Forms are used to create (rather primitive) GUIs on Web pages Usually.
24-Aug-14 HTML Forms. 2 What are forms? is just another kind of HTML tag HTML forms are used to create (rather primitive) GUIs on Web pages Usually the.
Ch3: Introduction to HTML5 part 2 Dr. Abdullah Almutairi ISC 340 Fall 2014.
JavaScript Forms Form Validation Cookies. What JavaScript can do  Control document appearance and content  Control the browser  Interact with user.
Supplement Creating Forms. Objectives Show how forms are used How to create the Form element HTML elements used for creating input fields.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
ColdFusion Code Security Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training
ColdFusion Code Security Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
Forms Review. 2 Using Forms tag  Contains the form elements on a web page  Container tag tag  Configures a variety of form elements including text.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
8/6/2015Auto Attendants 1 Smarter Communications.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
JavaScript Form Validation
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Project Four Forms Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule to a Web page.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
More on Fusebox at Fusebox Development Methodology : More on Fusebox at Fusebox Development Methodology.
Creating a Web Site to Gather Data and Conduct Research.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 7: Web Forms © 2007 Prosoft Learning Corporation All rights reserved ITD 110 Web Page Design.
Chapter 8 Cookies And Security JavaScript, Third Edition.
CIS 451: ASP.NET Objects Dr. Ralph D. Westfall January, 2009.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Using Client-Side Scripts to Enhance Web Applications 1.
Introduction to JavaScript 41 Introduction to Programming the WWW I CMSC Winter 2004 Lecture 17.
1 Forms and Form elements CSD 340 McCoey. 2 Form Object Properties action Usually a call to a server elements encoding method post or get target Methods.
Chapter 8 Collecting Data with Forms. Chapter 8 Lessons Introduction 1.Plan and create a form 2.Edit and format a form 3.Work with form objects 4.Test.
Website Development with PHP and MySQL Saving Data.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
ITCS373: Internet Technology Lecture 5: More HTML.
Application.cfm tips and Tricks Michael Smith President TeraTech, Inc ColdFusion, database & VB custom development and training.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
Creating Web Page Forms. Introducing Web Forms Web forms collect information from users Web forms include different control elements including: –Input.
Introduction to JavaScript CS101 Introduction to Computing.
HTML Forms. Slide 2 Forms (Introduction) The purpose of input forms Organizing forms with a and Using different element types to get user input A brief.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
WEB FORM DESIGN. Creating forms for a web page For your web project you have to design a form for inclusion on your web site (the form information should.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Week 10: HTML Forms HNDIT11062 – Web Development.
1/20 1 How to become a Guru Coder Michael Smith, TeraTech, Inc x110 Copyright.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Learning Aim C.  In this section we will look at how text, tables, forms and frames can be used in web pages.
Error Handling Michael Smith President TeraTech, Inc ColdFusion, Database & VB custom development
HTML Structure II (Form) WEEK 2.2. Contents Table Form.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
Day 22, Slide 1 CSE 103 Day 22 Non-students: Please logout by 10:12. Students:
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
IS1500: Introduction to Web Development
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Web Programming– UFCFB Lecture 17
MIS Professor Sandvig MIS 324 Professor Sandvig
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Unit 27 - Web Server Scripting
ColdFusion And Section 508 Michael Smith, President TeraTech, Inc
JavaScript Form Validation
Lesson 6: Web Forms.
Quick Guide for Online Ordering
Unit 5 Create Forms.
Presentation transcript:

ColdFusion Form Handling Michael Smith, President TeraTech, Inc ColdFusion, Database & VB custom development http://www.teratech.com 800-447-9120 http://www.teratech.com

Introduction Michael Smith President TeraTech Run MDCFUG CFUN-2k, CF2001 CF programmer and teacher Articles in CFDJ, CFAdvisor, Fusion Authority http://www.teratech.com

Why are Forms important? Valid data! Make site easy to use – or not! Layout indicates required fields Section 508 compliant Security – eg SQL add in, fake form submits and URL http://www.teratech.com

Form basics <FORM METHOD ACTION Submits via header or URL CF creates Form scope Structure Action to other form, self, email, JavaScript Other elements can submit via JavaScript – or auto self submit on timer! http://www.teratech.com

Validation Data type In range Text length Lookup lists Radio button or check box Credit card email Field by field vs form wide validation http://www.teratech.com

CFFORM CFINPUT CFSELECT CFTEXTINPUT CFSLIDER CFGRID CFTREE Onvalidate and and onerror extensions http://www.teratech.com

CFFORM pros and cons Creates JavaScript validation code Immediate feedback No refocus after error CF 5 big download Phone validation a bit strong Dreamweaver form elements Not 508 compliant http://www.teratech.com

_ field validation Hidden form fields _date, _required, _eurodate, _float, _integer, _range, _time <INPUT TYPE=“hidden” NAME=“mydatafield_required” VALUE=“Message” Works even if javascript turned off Can not use names with _date in them! Fake submit security bypass! Doesn’t work with GET http://www.teratech.com

JavaScript validations Onsubmit function Totally custom – eg multiple fields Harder to write and maintain Security issue Save server load Not 508 compliant Browser version dependent http://www.teratech.com

Submit page validations Most secure Most flexible More complex CFIF Table look ups Clean up data with val() and CFQUERYPARAM CGI.HTTP_REFERER http://www.teratech.com

Traps Check data type CFQUERY WHERE variables CFINPUT and CFUPDATE – beware Check boxes don’t exist Wacky characters like ‘ Submit page run directly File upload – must use multipart form <input type="File“ name=“file”> ENCTYPE”multipart/form-data” http://www.teratech.com

Where to submit to Method POST vs GET (default!) Myform_sub.cfm Self – use action = #CGI.SCRIPT_NAME#?#CGI.QUERY_STRING# Hidden fields for arguments Redisplay entered info plus error message Size issue with Get, much bigger with POST (text area may fill it!) http://www.teratech.com

Fusebox submit to index.cfm with fuse that: fusebox CF_REUSEFORM validates the data. If valid Insert SQL Else CFLOCATION to form with data filled out fusebox CF_REUSEFORM http://www.teratech.com

Credit card issues Don’t resubmit Review field page before processing Insert data before sending to credit card site in case of failure. http://www.teratech.com

References Ben Forta “Web Application Construction Kit” Chap 12, 14, 15, 23 Kristin Motlagh “Mastering CF” Chap 14, 15 Builder.com form validation basics http://www.teratech.com

Questions? Ask now… MDCFUG-L list … or email michael@teratech.com http://www.teratech.com

Sample code to cut and paste <!--- || BEGIN FUSEDOC || || Properties || Name: act_validate_new_account_data.cfm Author: || Responsibilities || I define the application wide parameters for the site. || Attributes || || END FUSEDOC ||---> || General || Name: Author: Martin Cadirola Copyright (c) 2000, 2001. All rights reserved Email: martin@ecotronics.com || History || || Purpose || This fuse is target of in_SubmitJob and err_SubmitJob. First thing is to convert all form fields to session variables, then work from there... Data that is not valid gets cleared so that err_SubmitJob shows erroneous data blank * roleID , a string. single value * position_types , a comma separated list * locations , a comma separated list * title * company_website * salaryrange_low * salaryrange_high * poc_phone * poc_fax * poc_email * astd_firstname * astd_lastname * astd_company * astd_phone * astd_email <!--- CONVERT ALL FORM VARIABLES INTO SESSION VARIABLES ---> <cf_FormFields2SessionVars> <!--- INITIALIZE VALIDATION VARIABLES: FLAG AND MSG ---> <cfset Data_Not_Valid = "False"> <cfset CLIENT.msgErrorCreateEditAccount = "" > <!--- If this user is a doctor, make sure the required fields are there For doctors, we need: DEA# EMAIL SPECIALTY STATE ---> <cfif isDefined("attributes.isdoctor") and attributes.isdoctor is "on"> <cfif attributes.client_DEA_number lt 5> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Please enter your DEA ##" & "<br>"> <cfset Data_Not_Valid = "True"> </cfif> <cfif Data_not_valid> <cfset CLIENT.msgErrorCreateEditAccount = "For doctors, we ask that you please fill out the following fields:<br>   * DEA##<br>   * EMAIL<br>   * SPECIALTY<br>   * STATE<br> #CLIENT.msgErrorCreateEditAccount#"> <!--- CHECK FOR TITLE ---> <!--- <cfif CLIENT.client_first_name is ""> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "First Name" & "<br>"> </cfif> ---> <cfif CLIENT.client_last_name is ""> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Last Name" & "<br>"> <!--- <cfif CLIENT.client_address1 is ""> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Address" & "<br>"> <!--- <cfif CLIENT.client_city is ""> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "City" & "<br>"> <!--- <cfif CLIENT.client_postal_code is ""> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Postal Code" & "<br>"> <cfif CLIENT.client_password is "" OR CLIENT.client_password_check is "" or CLIENT.client_password is NOT CLIENT.client_password_check> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Unable to validate passwords" & "<br>"> <cfif CLIENT.client_country_id is "233" and CLIENT.client_state_id is 1> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Please select your state" & "<br>"> <cfif CLIENT.client_country_id is "39" and CLIENT.client_state_id is 1> <cfif CLIENT.client_state_id is not 1> <CFIF CLIENT.client_country_id is not "39" AND CLIENT.client_country_id is not "233"> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "If you are outside the US or Canada, please choose Not In US/Canada for your state." & "<br>"> </CFIF> <cfset regex_phone_fax = "^[[:digit:]]{3}[-|[:space:]]?[[:digit:]]{3}[-|[:space:]]?[[:digit:]]{4}$"> <!--- Check for phone with valid syntax, when defined ---> <cfif CLIENT.client_country_id is "233" AND isDefined("CLIENT.client_telephone") AND CLIENT.client_telephone is not "" AND NOT REFind( regex_phone_fax, CLIENT.client_telephone)> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Your telephone number is not in the correct format" & "<br>"> <cfset regex_email = "^[[:alnum:]_\.\-]+@[[:alnum:]_\.\-]+\.[[:alpha:]]{2,3}$"> <!--- Check for email with valid syntax, when defined ---> <cfif isDefined("CLIENT.client_email") AND CLIENT.client_email is not "" AND NOT REFind( regex_email, CLIENT.client_email)> <cfset CLIENT.msgErrorCreateEditAccount = CLIENT.msgErrorCreateEditAccount & "Your email address is invalid." & "<br>"> <cfset CLIENT.poc_fax = ""> <CFIF Data_Not_Valid> <!--- Redirect to the form ---> <cflocation url="index.cfm/fuseaction/accounts_new_member/invalid_data/yes/reenterdata.htm" ADDTOKEN="No"> http://www.teratech.com