HTML Form Processing Learning Web Design – Chapter 9, pp 143-163 Squirrel Book – Chapter 11, pp 251-266.

Slides:



Advertisements
Similar presentations
PHP I.
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.
Lecture 6/2/12. Forms and PHP The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input When dealing with HTML forms.
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
Chapter 31 Basic Form-Processing Techniques JavaServer Pages By Xue Bai.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
A simple PHP application We are going to develop a simple PHP application with a Web interface. The user enters two numbers and the application returns.
Python and Web Programming
1 The World Wide Web. 2  Web Fundamentals  Pages are defined by the Hypertext Markup Language (HTML) and contain text, graphics, audio, video and software.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Uploading Files. Why? By giving a user the option to upload a file you are creating an interactive page You can enable users have a greater web experience.
File Upload Instructions and Information The File Upload utility is used for transferring files too large to send through the system. How it Works:
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
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.
1 CS 131 Wrap Up Fall 2008 What Good is Programming?
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Computer Concepts 2014 Chapter 7 The Web and .
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
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.
PHP Forms and User Input The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
Lecture 7 – Form processing (Part 2) SFDV3011 – Advanced Web Development 1.
JavaScript & jQuery the missing manual Chapter 11
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
CSCI 6962: Server-side Design and Programming Introduction to AJAX.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
06/10/2015AJAX 1. 2 Introduction All material from AJAX – what is it? Traditional web pages and operation Examples of AJAX use Creating.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Lecture # 6 Forms, Widgets and Event Handling. Today Questions: From notes/reading/life? Share Personal Web Page (if not too personal) 1.Introduce: How.
MySQL and PHP Internet and WWW. Computer Basics A Single Computer.
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.
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.
1 Chapter 9 – Cookies, Sessions, FTP, and More spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
ITCS373: Internet Technology Lecture 5: More HTML.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
XHTML & Forms. PHP and the WWW PHP and HTML forms – Forms are the main way users can interact with your PHP scrip Typical usage of the form tag in HTML.
PHP Open source language for server-side scripting Works well with many databases (e.g., MySQL) Files end in.php,.php3 or.phtml Runs on all major platforms.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
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.
ITM © Port, Kazman1 ITM 352 More on Forms Processing.
Creating Databases for Web applications Server side vs client side PHP basics Homework: Get your own versions of sending working: both html and Flash!
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
©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.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
Creating Databases applications for the Web: week 2 Basic HTML review, forms HW: Identify unique source for asp, php, Open Source, MySql, Access.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
JavaScript and Ajax (Internet Background) Week 1 Web site:
PHP Form Processing * referenced from
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
IN THIS LESSON WE WILL REVIEW THE STRUCTURE OF THE INTERNET AND HOW BROWSERS ASSEMBLE WEBSITES BASED ON INSTRUCTIONS THEY RECEIVE FROM SERVERS. Internet.
Unit 4 Working with data. Form Element HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons,
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
PHP – Hypertext Preprocessor.
Simple PHP Web Applications Server Environment
JavaScript and Ajax (Ajax Tutorial)
CS 330 Class 7 Comments on Exam Programming plan for today:
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Section 17.1 Section 17.2 Add an audio file using HTML
Dr. John P. Abraham Professor UTRGV eCommerce CSCI 6314
Presentation transcript:

HTML Form Processing Learning Web Design – Chapter 9, pp Squirrel Book – Chapter 11, pp

Web Client-Server Model http response http request Specify the URL of the “file” you want. Send back the “file” to the client.

What is in an http request? Obviously, the URL of the “file” you want. Anything else? Note: A URL not only helps you find the server, but it also tells the server what file you want.

What is in an http request? Information about the client browser – Firefox, IE, Safari, etc. – Browser Version – Platform (Windows, Unix, MacOS, etc.) Also the URL itself can include variables – ?pageid=48&display=wide

URL Variables ?pageid=48&display=wide ? Defines the URLs query string pageid and display are query variables & is a delimiter, i.e., put between query variables

Can an http request send anything else? Yes, It can send form variables to the server. HTML includes elements for creating forms – Text boxes – Buttons – Check boxes – Etc. The data entered into these form elements can be sent to the server using an http request.

HTML Forms Consider the following HTML code Enter When you click the submit button, the browser – requests the file “script.php” – and sends the server the data that user enters =

Summary: Data sent by client Message header 1.URL itself 2.URL variables 3.Form variables (method = “get”) Message body 1.Information about the client browser 2.Form variables (method = “post”) 3.Attached files

What does the server (Apache) do with the data? The Server 1.receives an http request 2.parses URL and message body of the http request 3.puts the data into variables (associative arrays) that can be used by any scripting language

Global Variables (created for every http request) $_GET – stores all the URL variables and form variables via method=“get” $_POST – stores all the Form variables via method =“post” $_SERVER – stores server information including info about the client browsers that just made the request. $_FILES – uploaded files sent via multi-part form

Example add.php <?php $xValue = $_GET['xval']; $yValue = $_GET['yval']; $sum = $xValue + $yValue; echo $xValue,' + ', $yValue, ' = ', $sum; ?> <?php $xValue = $_GET['xval']; $yValue = $_GET['yval']; $sum = $xValue + $yValue; echo $xValue,' + ', $yValue, ' = ', $sum; ?> 5+ 7 = 12

Example <?php $xValue = $_GET['xval']; $yValue = $_GET['yval']; $sum = $xValue + $yValue; echo $xValue,' + ', $yValue, ' = ', $sum; ?> <?php $xValue = $_GET['xval']; $yValue = $_GET['yval']; $sum = $xValue + $yValue; echo $xValue,' + ', $yValue, ' = ', $sum; ?> = 9

Get vs. Post <?php $sum = $_POST['xval'] + $_POST['yval'] echo $_POST['xval'],' + ', $_POST['yval'], ' = ', $sum; ?> <?php $sum = $_POST['xval'] + $_POST['yval'] echo $_POST['xval'],' + ', $_POST['yval'], ' = ', $sum; ?> = 9

GET vs. POST GET – First way Browser adds the form variables to the URL Then sends the http request Form variables are visible in the URL Browsers limit the length a URL Limit for IE is 2,048 characters POST – Improved way Browser adds the form variables to the message body of the http request Then sends the http request Must be used when sending non-text data, binary files, images, etc. Must be used when sending long data (> 2KB)

Details Client-side: The web browser extracts the form data, i.e., the values the user types, and the variables, i.e., the names of the form elements. places variables and values in either – the URL (if method=“get”) or – the body of the http request (if method=“post”). Server-side: The web server receives the http request. Parses the header of the http request which indicates if there are form variables. extracts the variables places them in a global associative arrays visible to the requested script.

One more look <?php $sum = $_POST['xval'] + $_POST['yval'] echo $_POST['xval'],' + ', $_POST['yval'], ' = ', $sum; ?> <?php $sum = $_POST['xval'] + $_POST['yval'] echo $_POST['xval'],' + ', $_POST['yval'], ' = ', $sum; ?> = 9

Quirks of Web-page Based Interfaces Ever notice the delay in submitting a form? Ever notice that forms tend to always send back a confirmation message, even when you don’t need one? Ever notice the page entirely refreshes whenever a button is clicked?

Mechanics of Web-based Interfaces User requests a FORM (add.html) Sends the FORM (add.html) User fills out the FORM and clicks submit Send FORM variables and requests action “add.php” Time Sends back output of “add.php” could be a new FORM Server receives the FORM variables Server executes “add.php” User fills out the new FORM and clicks submit Send FORM variables and requests new action

Synchronous Communication A Phone conversation is synchronous – Generally, people wait for an answer before asking the next question – You talk, I talk, you talk, I talk, … Web analogy – When submitting a form, you have to wait for a response before you can move to the next action. This is why web-interfaces are sometimes quirky: – We are used to asynchronous interaction. – Web client-server interaction is actually synchronous. – Note many “experts” mistakenly consider web client- server interaction to be asynchronous. They are wrong!

Asynchronous Communication is a classic example of asynchronous communication – You do NOT have to wait for an reply to send out other s. Web client-server analogy – You do NOT have to wait for an http response to send out another request, even to the same server When you look at it this way, web client-server interaction seems asynchronous, but it is not.

Why it appears Asynchronous Consider opening multiple browser windows and connecting to different servers Consider slow servers The response order is NOT always the same as the request order. This appears to be asynchronous communication like , but….

But… You can get an out of the blue. A software application can send a message out of the blue. Surprisingly, a web browser cannot get an http response without first making a request. Pop-ups are actually initiated by spyware or plug-ins that make requests without the user’s explicit action.

http is Synchronous A server won’t do anything unless the client makes a request. Then, the only thing the server can do is send back exactly one response. Truly asynchronous communication would mean – The server could initiate communication when appropriate. – A single request from a client could trigger more than one response from the server at any time

Confused? Here is a Summary The general communication between web client and web server has an asynchronous feel – because clients and servers support multiple simultaneous requests/responses However, http is a synchronous protocol – Requests from clients drive all the responses from servers In two weeks, we’ll learn about AJAX, which is a way to support true asynchronous communication between client and server.

Still Confused? A phone conversation is synchronous – You talk, I talk, you talk, I talk. Surfing the web is a synchronous conversation – Click a link (request), get a page (response), click a link (request), get a page (response) Web clients and servers support multiple simultaneous conversations. – Like having multiple mouths and sets of ears – The conversations feel asynchronous because you can switch from one to the other but they are really simultaneous synchronous conversations. – Take that! high paid web consultants who say http is asynchronous.

Why is this important? Synchronous form interaction is annoying. – You have to refresh an entire form just to update one part of it. – Then, you end up sending the entire form back again even if only part of it changed. Without using asynchronous frameworks like AJAX, synchronous form interaction is the only way to build web applications.

Example If there is time, we’ll look at a neat example Registration Form