Web Applications / Web Systems
Juan Pavón Mestras
Dep. Software Engineering and Artificial Intelligence
Facultad de Informática
Universidad Complutense Madrid
Licensed material Creative Commons
PHP – Interaction with the client
Forms
HTTP Protocol
The browser (client, user agent) requests a resource (page
HTML, image, video, etc.) to a server
Request: method that is used GET, POST, PUT, HEAD, etc.
Header fields
Blank line
Body of the message (text): can carry parameters of the form
The server responds by sending the resource or with a message of
error
Line status: status code (OK, Error) and associated text
Header fields
Blank line
Message body: the requested resource
Client
(Browser) [19659002] and
connection
1
request (GET / PO ST, …)
2
answer
80
x
Server
Juan Pavón – UCM 2012-13
close
3
PHP
] Parameter passing
The client request can take several parameters
Normally they are obtained from a form
How they are passed depends on the action indicated in the form
HTML in which they are collected data
GET: information request (idempotent operation)
GET queryphonephone.php? customer = company1
• Parameters are passed as name = value pairs
• Several parameters can be passed in succession with &
POST: requests that change server status
• Save or update data
• Send email
• Sort data
POST modify.php? Customer = company1 & phone = 917892893
Juan Pavón – UCM 2012-13
PHP
3
4
Typical scenario of in teraction (with GET)
http: //localhost/CursoPHP/hola.html
hi.html
please, give your name:
By
procesaform.php
<? Php
?>
$ client = $ _ REQUEST [“cliente”];
echo "Hello $ client";
Juan Pavón – UCM 2012-13
PHP
5
Typical scenario of interaction (with POST)
http: // localhost / CursoPHP / hello.html
hello.html
please, enter your name:
By
procesaform.php
<? Php
?>
$ client = $ _ REQUEST [“cliente”];
echo "Hello $ client";
Juan Pavón – UCM 2012-13
PHP
6
Forms
POST "/procesaform.php "
name =" value "
Juan Pavón – UCM 2012-13
PHP
Forms
Within a form there may be:
Any typical element of a web page [19659002] • Paragraphs, images, divisions, lists, tables, etc.
Form controls
• [19659083] •
No hay comentarios:
Publicar un comentario