Form Redisplaying.

Slides:



Advertisements
Similar presentations
MWD1001 Website Production Using JavaScript with Forms.
Advertisements

CHAPTER 3 MORE ON FORM HANDLING INCLUDING MULTIPLE FILES WRITING FUNCTIONS.
Unit 7 – Working with Forms 1. Creating a form 2. Accessing the submitted data 3. Common operations on forms.
Week 4  Using PHP with HTML forms  Form Validation  Create your own Contact form Please Visit:
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Lecture 6 – Form processing (Part 1) SFDV3011 – Advanced Web Development 1.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
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.
Let’s Make An Form! Bonney Armstrong GD 444 Westwood College February 9, 2005.
Week 7. Lecture 3 PHP Forms. PHP forms In part 2 of this course, we discussed html forms, php form is similar. Lets do a quick recap of the things we.
CO1552 Web Application Development HTML Forms, Events and an introduction to JavaScript.
NMD202 Web Scripting Week3. What we will cover today Includes Exercises PHP Forms Exercises Server side validation Exercises.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Part 2 Lecture 9 PHP Superglobals and Form Handling.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
1 Project 3 The Kumquat Society Conference. 2 Conference Registration In this project you will write a program to handle a conference registration. The.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
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.
Simple PHP Web Applications Server Environment
Testing and delivery Web design principles. Web development is software development.
Doing Something with All that Data!. On Submit…the data from a form is sent to the.php file listed under action.
JavaScript, Sixth Edition
CHAPTER 10 JAVA SCRIPT.
Validation.
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Project 1 - Individual Student Project
ITM 352 More on Forms Processing
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
THIS IS TO EVIDENCE YOUR WORK AND GET THE BEST GRADE POSSIBLE
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
EXCEPTION HANDLING IN SERVER CLIENT PROGRAMMING
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
Collecting Information from the User
Building components for your automation framework
ITM 352 Cookies.
The Pseudocode Programming Process
Chapter 4: Control Structures
Passing variables between pages
Indexer AKEEL AHMED.
Basic Contact Form user sends an
Web Programming– UFCFB Lecture 17
Validation.
Cookies BIS1523 – Lecture 23.
Simple PHP application
Unit 27 - Web Server Scripting
Web Systems Development (CSC-215)
Department Array in Visual Basic
Conditions and Ifs BIS1523 – Lecture 8.
Processing a Travel Claim
Conditionally Confirming a Submit
In Class Programming BIS1523 – Lecture 11.
Virtual Simulator Extreme (VirSim Ex)
Introduction to the Invention Logsv2
PHP: Combo box FdSc Module 109 Server side scripting and
Creating Forms on a Web Page
Arrays Topics Definition of a Data Structure Definition of an Array
Unemployment Insurance Agency Michigan Web Account Manager
How to Submit your Booking Requests?
CBMS Transformation Address Tip Sheet
Flowcharts and Pseudo Code
Subscription & IP Warmup strategy
The Selection Structure
2008/11/19: Lecture 18 CMSC 104, Section 0101 John Y. Park
PHP-II.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2016 Section DA MW 4:05-5:20
Arrays Topics Definition of a Data Structure Definition of an Array
Module 4 Loops and Repetition 9/19/2019 CSE 1321 Module 4.
ME 123 Computer Applications I Lecture 8: System of Equations 3/21/03
Web Forms.
Presentation transcript:

Form Redisplaying

Eh? Now we know how to check whether or not user inputs conform to our rules… … we need to handle gracefully when they fail! User inputs come from forms, and we need to work out how to re-display forms on input validation failure.

What are we shooting for? Bullet-proof validation. On validation failure, form should be re-displayed to the user. Don’t make the user fill in fields again that they’ve already done correctly. We want to have to write the form html only once. If validation fails, the user needs some feedback.

The One True Way? There are multiple ways to achieve this.. I am going to demonstrate ONE way, but you should be aware that it’s not the ONLY way.

Single Page Make the form submit to the same page. Why? It keeps everything in one place, and means you only write the form once. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" …

Page Logic if (form has been submitted) { // validate form } if (valid submission) { // action data } else { // (re)display form

Validation.. if (form has been submitted) { // validate form } …can be implemented as… if (isset($_POST[‘submit’])) {

Maintain separation $_POST $clean UNSAFE SAFE Maintaining separation between validated and un-validated data helps prevent you make mistakes. $_POST $clean UNSAFE SAFE

Accumulate errors.. $errors = 0; $errmsg = ‘’; $clean = array(); if (isset($_POST[‘submit’])) { if ($_POST[‘value’] is VALID) { $clean[‘value’] = $_POST[‘value’]; } else { $errors++; $errmsg .= ‘data not valid because…’; } // continue testing other fields..

Now to action or display.. if (form has been submitted) { // validate form } if (valid submission) { // action data } else { // (re)display form

Now to action or display.. if (isset($_POST[‘submit’])) && $errors===0) { // action data } else { // (re)display form }

Redisplay form (1) // if (re)displaying form: print // error message if redisplaying if ($error>0) { echo “<p>errors: $errmsg</p>"; }

Redisplay form (2) <label for=“email">Email:</label> <input name=“email" size="40" value="<?php echo isset($clean[‘email']) ? htmlentities($clean[‘email']) : ‘default'; ?>" id=“email" type="text“ />