Beruflich Dokumente
Kultur Dokumente
between pages
Summary of the
previous lecture
Operators in PHP
Conditional Statements in PHP
Looping Statements
Arrays in PHP
Outline
Super Global variables
Passing variables between pages
Using
Using
Using
Using
query strings
sessions
cookies
forms
Super Global
Variables
$_GET: contains all the query string
variables that were attached to the
URL
Passing variables
through URL
Passing variables through pages URL
http://www.mydomain.com/news/articles/
showart.php?id=12345
http://www.mydomain.com/news/articles/
showart.php?id=12345&lang=en
Disadvantages
Everyone can see the values of the variables
Users can arbitrarily change the variable
6
Session
variable is
created
Link to the
next page
Session variable is
accessed
link
Session
variables
value
10
3. Passing variables
using sessions
session_start()- is used to start a
session
$_SESSION[variable_name]- is
used to store data in session
variable
session_destroy()- is used to
destroy a session
unset($_SESSION[variable_name])
- is used to unset a specific
variable
12
Session is
accessed
13
?>
17
Sessions
Practically unlimited
space
No user control
18
Input
field
name
Value
entered by
user
21
22
nam
e
Asad
asd@gmail.
com
sub
mit
asd@gmail.c
Asad
om
23
24
Asad
asd@gmail.
comsub
mit
nam
e
Asad
asd@gmail.c
om
Ation.php
<?php
$name =
$_GET[name];
$email =
$_GET[email];
?>
25
Asad
asd@gmail.
comsub
mit
nam
e
Asad
asd@gmail.c
om
Ation.php
<?php
$name =
$_POST[name];
$email =
$_POST[email];
?>
26
Text
field
Text
field
name
27
Display a
message
28
We are at form
page
We are on
action page
29
Hidde
n field
Field
name
Hidden
value
Accessing
hidden value
30
31
name
value
Getting
value of
C
Getting
value of
VB
32
33
34
Value is
set
Value is not
set
Getting value
of radio
35
36
37
38
Summary
Super global variables
Passing data between pages
39
References
Chapter 2, Beginning
PHP6,Apache,Mysql web
development by Matt Doyle, Wrox
publishers, 2009, ISBN: 0470413964
Chapter 13, Beginning PHP and
MySQL by W. Jason Gilmore, Apress
publisher, 4th edition; 2010, ISBN-13
(electronic): 978-1-4302-3115-8.
40