php workshop l03 superglobals
TRANSCRIPT
Web Basics Programming With PHP
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
Lesson 2 Overview:
$_GET & $_POST2
Session3
Homework :P4
Include1
• Why ?
To insert the content of one PHP file into another PHP file before the server executes it.
• Syntax:
Include & Require
include 'filename';
or
require 'filename';
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
Get
• What is GET ?
An associative array of variables passed to the current script via the
URL parameters.
• Example:
www.mysite.com/index.php?p=home&s=1
• How can i catch the data ?
$page = $_GET[‘p’] ;
$start = $_GET[‘s’];
• When to use ?
when Information that sent is visible to everyone.
• What about security ?
Not Safe ! Need some efforts ..
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
POST
• What is POST?
An associative array of variables passed to the current script via the
HTTP POST method.
• Example:
using form tag.
• How can i catch the data ?
$name = $_POST[‘name’];
$pass = $_POST[‘pass’];
• When to use ?
when Information that sent is invisible to others.
• What about security ?
Not Safe ! But better than GET Need some efforts ..
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
GET vs POST
• Both GET and POST create an array
This array holds key/value pairs, where keys are the names of the form
controls and values are the input data from the user.
• Both GET and POST are treated as $_GET and $_POST.
These are “superglobals”, which means that they are always accessible,
regardless of scope - and you can access them from any function, class
or file without having to do anything special.
• $_GET is an array of variables passed to the current script via the URL
parameters.
• $_POST is an array of variables passed to the current script via the
HTTP POST method.
By: Mohammad Al-Shalabi & Mohammad Opada Al-Bosh
Session
• A PHP Session variable is used to store information about the user, or
change settings for a user session.
• Session variables hold information about one single user, and are
available to all pages in one application.
• session_start() Start new or resume existing session.
• session_destroy() Reset your session and you will lose all your stored
session data.
• Example :
$_SESSION['views']=1;
THANK YOU!
Your Logo