Understanding HTTP Requests: URL Variables, Form Data, and Server Processing, Slides of Web Design and Development

The components of an http request, including the url itself, url variables, information about the client browser, and form data. It also discusses how the server processes and uses this data.

Typology: Slides

2012/2013

Uploaded on 04/30/2013

aradhana
aradhana 🇮🇳

4.6

(8)

119 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
HTML Form Processing
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Understanding HTTP Requests: URL Variables, Form Data, and Server Processing and more Slides Web Design and Development in PDF only on Docsity!

HTML Form Processing

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?

• Information about the client browser

  • Firefox, IE, Safari, etc.
  • Browser Version
  • Platform (Windows, Unix, MacOS, etc.)

• Also the URL itself can include variables

  • http://www.site.com/makepage.php ?pageid=48&display=wide

URL Variables

http://www.site.com/makepage.php ?pageid=48&display=wide

•? Defines the URLs query string

• pageid and display are query variables

• & is a delimiter, i.e., put between query

variables

HTML Forms

• Consider the following HTML code

Enter Email:

• When you click the submit button, the browser

  • requests the file “ script.php
  • and sends the server the data that user enters

email = “[email protected]

Summary: Data sent by client

1. URL itself

2. URL variables

3. Information about the client browser

4. Any form data

Variables provided by the server.

• $_GET – stores all the URL variables

• $_POST – stores all the Form variables

• $_SERVER – stores server information

including info about the client browsers that

just made the request.

Example

• http://www.site.com/add.php? xval=5 & yval=

• add.php

<?php

$xValue = $_GET['xval'];

$yValue = $_GET['yval'];

$sum = $xValue + $yValue;

echo $xValue,' + ', $yValue, ' = ', $sum;

Get vs. Post

$sum = $_POST ['xval'] + $_POST ['yval']

echo $_POST ['xval'],' + ', $_POST ['yval'], ' = ', $sum;

?>

+
4 5

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, 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)

One more look

$sum = $_POST ['xval'] + $_POST ['yval']

echo $_POST ['xval'],' + ', $_POST ['yval'], ' = ', $sum;

?>

+
4 5

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?

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

  • Email is a classic example of asynchronous

communication

  • You do NOT have to wait for an email reply to send

out other emails.

  • 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.