1. Trang chủ
  2. » Mẫu Slide

Slide môn học PHP session 3 form handling in PHP

21 235 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 21
Dung lượng 144 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

 Use the GET Method  Use the POST Method  Retrieve data from forms using variables  Use hidden fields... Forms - II On submission of the form, the information is sent to the Web ser

Trang 1

Form Handling in PHP

Session 2

Trang 2

Review - I

developing dynamic web pages

 Security for user inputs

 New constructions for languages

Trang 3

Review - II

 PHP is used for generating the following:

 Files in formats like PDF and HTML

 Emails

 Graphical images like GIF and PNG

 PHP script has the following tags:

 <?php: Start tag

 ?>: End tag

 HTTP protocol is divided into following three parts:

Trang 4

Review - III

It sends the HTTP commands to the server through HTTP

protocols.

These tools are the program text editors

on Linux platform

Trang 5

 Use the GET Method

 Use the POST Method

 Retrieve data from forms using variables

 Use hidden fields

Trang 7

Forms - II

 On submission of the form, the information is sent

to the Web server, which in turn passes the

information to the PHP script engine

 Script engine processes the information,

manipulates it, and sends the output back to the Web

browser

Trang 8

Forms - III

 A form consists of the following attributes:

 Action: Specifies the Uniform Resource Locator

(URL) that will process the form data and send the

feedback

 Method: Specifies the method by which data is to be sent to the URL

Trang 9

 Information on the form is transmitted in the structure

of name/value pairs to the URL

Trang 10

GET Method - II

 Multiple name/value pairs can be sent to the URL by separating each pair with the ampersand (&) sign

 Name/value pairs are similar to variables

 Once name/value are on the Web server for processing, PHP make them available as variables

 Name/value pairs sent to the URL is a query string

 GET Method transmits only limited data

Trang 11

POST Method - I

 Specifies the Web browser to send all the user

information through the body of the HTTP request

 Transmits more information through the body of

the HTTP request, as there no physical limit on the

amount of information passed through the body of

the HTTP request

Trang 12

POST Method - II

 Information sent by the POST method is not

encrypted As a result, it is easily accessible

to a hacker.

 In order to make the information to be

secure, it is necessary to establish a secure

server connection

Trang 13

Difference in GET and POST - I

 GET method sends information through the URL

whereas the POST method sends information through the body of the HTTP request

 GET method is less secure as all the users are able to view the transmitted information in the URL

 GET method enables to transmit less amount of information as compared to the POST

Trang 14

Difference in GET and POST - II

 In the GET method, the pages loaded are carefully

book-marked, whereas in POST method the pages

loaded are not properly book-marked

 GET method retrieves the information whereas the

POST method manipulates the information on the

Web server

Trang 15

Retrieving Data Using GET

which the data is to be stored

Trang 16

Retrieving Data Using POST

Method

method, the syntax is:

$varname=$_POST[‘variable’];

Where,

 varname - Specifies the name of the variable in which

the data is to be stored

 POST[‘variable’] - Specifies the name of the input

variable

Trang 17

Hidden Fields - I

 Hidden form field enables to pass information to the Web server

 Hidden field is similar to the text field

 The difference is that the user cannot view the hidden field and its contents

 To view whether the form contains the hidden field, the user needs to view the HTML source code of the

Trang 18

Hidden Fields - II

 The syntax to define the hidden filed is:

<INPUT TYPE=HIDDEN NAME=hidden1

VALUE=”PHP MESSAGE”>

Where,

 INPUT TYPE - Specifies that the field is hidden

 NAME - Specifies the name of the hidden field

Trang 19

the script engine

Trang 20

Summary - II

closing <FORM> tags

automatically becomes a part of the form

Trang 21

Summary - III

 POST method informs the browser to send the values

the user placed on the form to the PHP script engine in

the body of the HTTP request

 Hidden form fields enables form developers to pass

information, from a form to a script, or from one form

to another, before being passed to a script

 Hidden form fields are not visible to users

Ngày đăng: 30/11/2016, 22:11

TỪ KHÓA LIÊN QUAN