PHP Form Handling. Prof. Jim Whitehead CMPS 183 Spring 2006 May 3, 2006



Similar documents
HTML Forms. Pat Morin COMP 2405

HTML Form Widgets. Review: HTML Forms. Review: CGI Programs

Internet Technologies

<option> eggs </option> <option> cheese </option> </select> </p> </form>

HTML Forms and CONTROLS

Web Design and Development ACS Chapter 13. Using Forms 11/30/2015 1

XHTML Forms. Form syntax. Selection widgets. Submission method. Submission action. Radio buttons

2- Forms and JavaScript Course: Developing web- based applica<ons

07 Forms. 1 About Forms. 2 The FORM Tag. 1.1 Form Handlers

Working with forms in PHP

HTML Tables. IT 3203 Introduction to Web Development

Further web design: HTML forms

FORM-ORIENTED DATA ENTRY

By Glenn Fleishman. WebSpy. Form and function

Dreamweaver Tutorials Creating a Web Contact Form

CGI Programming. What is CGI?

Web Development 1 A4 Project Description Web Architecture

CS412 Interactive Lab Creating a Simple Web Form

c. Write a JavaScript statement to print out as an alert box the value of the third Radio button (whether or not selected) in the second form.

Tutorial 6 Creating a Web Form. HTML and CSS 6 TH EDITION

TCP/IP Networking, Part 2: Web-Based Control

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Designing and Implementing Forms 34

In order for the form to process and send correctly the follow objects must be in the form tag.

Using Form Tools (admin)

Introduction to XHTML. 2010, Robert K. Moniot 1

PHP Tutorial From beginner to master

A MODEL FOR THE AUTOMATION OF HTML FORM CREATION AND VALIDATION. Keywords: html, form, web, automation, validation, class, model.

JavaScript and Dreamweaver Examples

Upload Center Forms. Contents. Defining Forms 2. Form Options 5. Applying Forms 6. Processing The Data 6. Maxum Development Corp.

Inserting the Form Field In Dreamweaver 4, open a new or existing page. From the Insert menu choose Form.

Viewing Form Results

Manual for CKForms component Release 1.3.4

FORMS. Introduction. Form Basics

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. Web Design in Nvu Workbook 1

Forms, CGI Objectives. HTML forms. Form example. Form example...

InPost UK Limited GeoWidget Integration Guide Version 1.1

Chapter 5 Configuring the Remote Access Web Portal

InternetVista Web scenario documentation

<?php if (Login::isLogged(Login::$_login_front)) { Helper::redirect(Login::$_dashboard_front); }

Dynamic Web-Enabled Data Collection

How to Make a Working Contact Form for your Website in Dreamweaver CS3

Intell-a-Keeper Reporting System Technical Programming Guide. Tracking your Bookings without going Nuts!

Chapter 2: Interactive Web Applications

Configuring iplanet 6.0 Web Server For SSL and non-ssl Redirect

Linklok URL TM V2.90

Website Login Integration

User Guide for Smart Former Gold (v. 1.0) by IToris Inc. team

Motivation retaining redisplaying

Web Programming with PHP 5. The right tool for the right job.

Introduction to Ingeniux Forms Builder. 90 minute Course CMSFB-V6 P

Table of Contents. Welcome Login Password Assistance Self Registration Secure Mail Compose Drafts...

Livezilla How to Install on Shared Hosting By: Jon Manning

Webforms on a Drupal 7 Website 3/20/15

Phishing by data URI

FusionPro Links Microsite Creation Guide

DeltaPAY v2 Merchant Integration Specifications (HTML - v1.9)

FrontPage 2003: Forms

Dynamic Content. Dynamic Web Content: HTML Forms CGI Web Servers and HTTP

Website Planning Checklist

MSOW. MSO for the Web MSONet Workstation Configuration Guide

WIRIS quizzes web services Getting started with PHP and Java

Integrate your website with Worldpay in 5 steps

UNIVERSITY OF CALGARY Information Technologies WEBFORMS DRUPAL 7 WEB CONTENT MANAGEMENT

Client-side Web Engineering From HTML to AJAX

A Complete Guide to HTML Form Output for SAS/IntrNet Developers Don Boudreaux, SAS Institute Inc., Austin, TX

ART 379 Web Design. HTML, XHTML & CSS: Introduction, 1-2

GTPayment Merchant Integration Manual

Tutorial: Creating a form that s the results to you.

Shasta College SharePoint Tutorial. Create an HTML Form

Form Mail Tutorial. Introduction. The cgi-bin

Using Internet or Windows Explorer to Upload Your Site

SETTING UP AND RUNNING A WEB SITE ON YOUR LENOVO STORAGE DEVICE WORKING WITH WEB SERVER TOOLS

CREATING AND PROCESSING HTML FORMS

Real SQL Programming 1

Application Security

understand how image maps can enhance a design and make a site more interactive know how to create an image map easily with Dreamweaver

CREATING WEB FORMS WEB and FORMS FRAMES AND

UOFL SHAREPOINT ADMINISTRATORS GUIDE

CSCI110 Exercise 4: Database - MySQL

TABLE OF CONTENTS. 1) Introduction 2. 2) Installation 3. 3) Backend functionality 4. 4) Frontend functionality 9

Chapter 15: Forms. User Guide. 1 P a g e

BreezingForms Guide. 18 Forms: BreezingForms

Quick Start Guide. Installation and Setup

Chapter 3. Working with Forms

Research Electronic Data Capture Prepared by Angela Juan

Hello World RESTful web service tutorial

FireBLAST Marketing Solution v2

Chapter 22 How to send and access other web sites

Advanced Web Development SCOPE OF WEB DEVELOPMENT INDUSTRY

Transcription:

PHP Form Handling Prof. Jim Whitehead CMPS 183 Spring 2006 May 3, 2006

Importance A web application receives input from the user via form input Handling form input is the cornerstone of a successful web application everything else builds on it

Overview The browser interprets the HTML source for a particular page Result is a combination of text, images, and entry fields Each entry field has a specific name User fills in these fields, (with potentially some client-side input checking via JavaScript) and then selects a submission button The browser reads the input fields, and creates a message that is sent to the server A series of name, value pairs

HTML Form Creation FORM Encloses all input fields Defines where and how to submit the form data INPUT Defines a specific input field TEXTAREA Creates a free-form text fill-in box SELECT Creates a menu OPTION defines options within the menu

FORM FORM attributes action URL of the resource that receives the filled-in form This is the URL of your PHP code that receives the input method Choices are get or post you should choose post enctype MIME type used to send results. By default is application/xww-form-urlencoded Would use multipart/form-data if submitting a file (INPUT, type=file) <FORM action= MyHandler.php method= post >

INPUT INPUT attributes type: the kind of user input control name: the name of the control This gets passed through to the handling code In PHP: $_POST[ name ] value: initial value of the control size: initial width of the control in pixels, except for text and password controls maxlength: for text/password, maximum number of characters allowed checked: for radio/checkbox, specifies that button is on src: for image types, specifies location of image used to decorate input button

INPUT Control Types text: single input line password: single input line, with input characters obfuscated checkbox: creates a check list radio: creates a radio button list (checkbox, where inputs are mutually exclusive only one input at a time) button: push button hidden: a hidden control. No input field is visible, but value is submitted as part of the form

INPUT control types Special buttons submit: the submit button. Causes input to be sent to the server for processing reset: the reset button. Causes all input fields to be reset to their initial values File upload file: creates a file upload control

Example From HTML 4.1 specification <FORM action="http://people.ucsc.edu/~ejw/m yhandler.php" method="post"> <P> First name: <INPUT type="text" name="firstname"><br> Last name: <INPUT type="text" name="lastname"><br> email: <INPUT type="text" name="email"><br> <INPUT type="radio" name="sex" value="male"> Male<BR> <INPUT type="radio" name="sex" value="female"> Female<BR> <INPUT type="submit" value="send"> <INPUT type="reset"> </P> </FORM>

Receiving form input in PHP Upon receiving a form submission, PHP automatically creates and populates two arrays with the form input data Either: _POST[] or _GET[], depending on the FORM method type (post or get) Also: HTTP_POST_VARS[] or HTTP_GET_VARS[] Also: $name Requires register_globals option, and is generally a bad idea due to cross-site attacks Additionally, _REQUEST[] is also created The array indicies are the names of the form variables (INPUT name= ) The array value is the user entry data

Validating Data All web applications must validate user input data Ensure the data is syntactically correct, and meets input constraints Ideally want one PHP page to create form, validate input, and handle correct input This is a little tricky

All-in-one Input Handling Page Overall logic: If first time displaying page Then Create form with initial default values Else have just received user input Then Validate input If input not valid Then Redisplay page, with just-received user input data as default values (so as not to lose the user s input) Else Handle the input (typically by writing it to a database) Proceed to next screen in the web application

How to determine if first time Can check if the $_POST[] array is empty Will be empty first time through if (empty($_post)) { create initial form } if (!empty($_post)) { validate input }

All-in-one structure Functions for input validation Function(s) that creates form Default values set from contents of _POST[] HTML preamble Create initial form Validate input Recreate form Code to handle valid input HTML end

Libraries There are many libraries that exist for handling input, and performing validation These libraries can also create client-side Javascript for client-side value checking PEAR HTML_quickform is one example