SlideShare une entreprise Scribd logo
1  sur  25
PHP Forms
 GET and POST Method
 Form Validation
 Form Required Fields
*Property of STI K0032
GET and POST Method
A form data can be submitted using POST
and GET method
Both are used for same purpose but stand
apart for some specifications
GET and POST create an array which holds
key/value pairs, where keys are the name of
the form controls and values are the input
data by the user
*Property of STI K0032
GET and POST Method
Both GET and POST method are treated as
$_GET and $_POST in PHP
These methods are superglobals, which
means that they are always accessible, and
they can be accessed using any function,
class or file
The $_GET method is an associative array of
variables passed to the current script via the
URL parameters
*Property of STI K0032
GET and POST Method
The $_POST method is an array of variables
passed to the current script via the HTTP
POST method
In this method the information is
transferred in a hidden manner
A form that submits information is
appended to the URL in the form of Query
String which consists of name = value pairs
in URL known as URL Encoding
*Property of STI K0032
GET and POST Method
This string contains user values/data, which
are joined using equal (=) signs, separated
by ampersand (&), and spaces are removed
and replaced with plus (+) sign
Name1=value1&name2=value2&name3=value3
*Property of STI K0032
Get Method
 http:/.www.example.com/index.html?
name=mel@email.com&contact=09176543210
 The code below is a client-side HTML form using
method=“get” for user to fill the information
*Property of STI K0032
Get Method
 The code below is the server-side PHP script
where, $_GET associative array is used to receive
sent information from server end
*Property of STI K0032
Post Method
<form action="#" method="post">
....
</form>
Below is a server-side PHP script where $_POST associative
array is used to receive sent information at server end
*Property of STI K0032
Form validation
*Property of STI K0032
Form validation
The form shown in Figure 6.1 consists of the
following elements:
 Name (required field - must contain letters and
whitespaces)
 E-mail (required field - must contain valid email address)
 Website (optional field - if present, must contain valid
website URL)
 Comments (optional field - a multi-line text field)
 Gender (required field - must select a radio button )
*Property of STI K0032
Form Elements
The Name, E-mail, Website are input
elements
Input elements, in particular, used text and
submit values for its types attribute in order
to create text fields and buttons
The HTML code:
*Property of STI K0032
Form Elements
Radio button shows several options to the
users from which the user may select one
HTML Code:
*Property of STI K0032
Form Elements
The text area is typically a large text field
with multiple rows
The textarea element has three attributes –
name, rows, and cols attribute
HTML code:
*Property of STI K0032
Form Elements
 list element offers options from which the user might
choose. A list can be created using the select element,
within which is nested option elements for each option to
appear
 The select element has a name attribute giving the name
for the browser to use when identifying the selection
when the form is submitted
 The option element has a value attribute for specifying
what value to send when that option is selected, and it has
a select attribute which allows the HTML to specify which
option is initially selected. The code
*Property of STI K0032
Form Elements
 HTML Code:
*Property of STI K0032
Form Element
 The HTML code of the form element:
 when the form is submitted, the form data is sent with
method=”post”
 So, the $_SERVER["PHP_SELF"] sends the submitted
forms data to the page itself, instead of jumping to a
different page
*Property of STI K0032
Form Element
 The $_SERVER["PHP_SELF"] is a super global
variable that returns the filename of the currently
executing script
 Htmlspecialchars() function converts special
characters to HTML entities
 Cross-site scripting (XSS) is a type of computer
security vulnerability typically found inWeb
application
*Property of STI K0032
Form Element
 Example: test_form.php
 if a user enters the normal URL in the address bar like
"http://www.example.com/test_form.php", the above code
will be translated to:
*Property of STI K0032
Form Element
 consider that if a user enters the following URL in
the address bar:
http://www.example.com/test_form.php/%22%3E
%3Cscript%3Ealert('hacked')%3C/script%3E
 will be translated to:
*Property of STI K0032
Form Element
be aware that any JavaScript code can
be added inside the <script> tag
A hacker can redirect the user to a file on
another server, and that file can hold
malicious code that can alter the global
variables or submit the form to another
address to save the user’s data
*Property of STI K0032
how to avoid $_SERVER[“PHP_SELF”] exploit?
The $_SERVER[“PHP_SELF”] exploit can be
avoided using the htmlspecialchars()
function
if the user tries to exploit the PHP_SELF
variable, it will result:
*Property of STI K0032
Validate Form Data with PHP
 The very first thing to do to validate form data with PHP is
to pass all variables through PHP’s htmlspecialchars()
function
 For example:
 With htmlspecialchars() function it would not be executed,
because it would be saved as HTML escaped code like this:
*Property of STI K0032
test_input()
*Property of STI K0032
Form Required Fields
 In the previous slide, all input fields were optional,
meaning no required fields to be filled in by the
user
 Here is a simple PHP script that checks the name
for empty input and throws an error message if
the input is empty:
*Property of STI K0032
Form Required Fields
To display the error message in the HTML form (this
will be generated if the user tries to submit the form
without filling in the required fields) use the code
below:

Contenu connexe

Tendances (20)

Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligeti
 
PHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and requirePHP - DataType,Variable,Constant,Operators,Array,Include and require
PHP - DataType,Variable,Constant,Operators,Array,Include and require
 
Get method and post method
Get method and post methodGet method and post method
Get method and post method
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Chapter 07 php forms handling
Chapter 07   php forms handlingChapter 07   php forms handling
Chapter 07 php forms handling
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Forms in html5
Forms in html5Forms in html5
Forms in html5
 
Oops concepts in php
Oops concepts in phpOops concepts in php
Oops concepts in php
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Class 5 - PHP Strings
Class 5 - PHP StringsClass 5 - PHP Strings
Class 5 - PHP Strings
 
PHP Cookies and Sessions
PHP Cookies and SessionsPHP Cookies and Sessions
PHP Cookies and Sessions
 
Loops PHP 04
Loops PHP 04Loops PHP 04
Loops PHP 04
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
4.2 PHP Function
4.2 PHP Function4.2 PHP Function
4.2 PHP Function
 
PHP
PHPPHP
PHP
 
Html form tag
Html form tagHtml form tag
Html form tag
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Uploading a file with php
Uploading a file with phpUploading a file with php
Uploading a file with php
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
PHP Form Validation Technique
PHP Form Validation TechniquePHP Form Validation Technique
PHP Form Validation Technique
 

En vedette

Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In PhpHarit Kothari
 
Php Form
Php FormPhp Form
Php Formlotlot
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemAzharul Haque Shohan
 
Forms and Databases in PHP
Forms and Databases in PHPForms and Databases in PHP
Forms and Databases in PHPMike Crabb
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in phpherat university
 
Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHPThomas Weinert
 
Script login form php
Script login form phpScript login form php
Script login form phpHanief Rpl
 
03 the htm_lforms
03 the htm_lforms03 the htm_lforms
03 the htm_lformsIIUM
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationNicole Ryan
 
Geek Austin PHP Class - Session 4
Geek Austin PHP Class - Session 4Geek Austin PHP Class - Session 4
Geek Austin PHP Class - Session 4jimbojsb
 
S.G.Balaji Resume
S.G.Balaji ResumeS.G.Balaji Resume
S.G.Balaji ResumeBalaji Sg
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with phpJoe Ferguson
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An IntroductionJacques Woodcock
 

En vedette (20)

3 php forms
3 php forms3 php forms
3 php forms
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
Php Form
Php FormPhp Form
Php Form
 
Making web forms using php
Making web forms using phpMaking web forms using php
Making web forms using php
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
 
Forms and Databases in PHP
Forms and Databases in PHPForms and Databases in PHP
Forms and Databases in PHP
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
PHP Making Web Forms
PHP Making Web FormsPHP Making Web Forms
PHP Making Web Forms
 
Deliver Files With PHP
Deliver Files With PHPDeliver Files With PHP
Deliver Files With PHP
 
Script login form php
Script login form phpScript login form php
Script login form php
 
Get and post methods
Get and post methodsGet and post methods
Get and post methods
 
03 the htm_lforms
03 the htm_lforms03 the htm_lforms
03 the htm_lforms
 
Using arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing informationUsing arrays with PHP for forms and storing information
Using arrays with PHP for forms and storing information
 
Geek Austin PHP Class - Session 4
Geek Austin PHP Class - Session 4Geek Austin PHP Class - Session 4
Geek Austin PHP Class - Session 4
 
S.G.Balaji Resume
S.G.Balaji ResumeS.G.Balaji Resume
S.G.Balaji Resume
 
Ns3
Ns3Ns3
Ns3
 
PHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and SessionsPHP - Introduction to PHP Cookies and Sessions
PHP - Introduction to PHP Cookies and Sessions
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with php
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An Introduction
 

Similaire à Php forms

Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptxSherinRappai
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4Mudasir Syed
 
Forms With Ajax And Advanced Plugins
Forms With Ajax And Advanced PluginsForms With Ajax And Advanced Plugins
Forms With Ajax And Advanced PluginsManuel Lemos
 
9780538745840 ppt ch04
9780538745840 ppt ch049780538745840 ppt ch04
9780538745840 ppt ch04Terry Yoast
 
331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheet331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheetstephen972973
 
Html5ppt
Html5pptHtml5ppt
Html5pptrecroup
 
New Form Element in HTML5
New Form Element in HTML5New Form Element in HTML5
New Form Element in HTML5Zahra Rezwana
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Mohd Harris Ahmad Jaal
 
FORMS IN PHP contains various tags and code
FORMS IN PHP contains various tags and codeFORMS IN PHP contains various tags and code
FORMS IN PHP contains various tags and codesilentkiller943187
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Gheyath M. Othman
 
Common gateway interface
Common gateway interfaceCommon gateway interface
Common gateway interfaceAnandita
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...SharePoint Saturday NY
 

Similaire à Php forms (20)

forms.pptx
forms.pptxforms.pptx
forms.pptx
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
 
Web forms and html lecture Number 4
Web forms and html lecture Number 4Web forms and html lecture Number 4
Web forms and html lecture Number 4
 
Html forms
Html formsHtml forms
Html forms
 
Chapter09
Chapter09Chapter09
Chapter09
 
Forms With Ajax And Advanced Plugins
Forms With Ajax And Advanced PluginsForms With Ajax And Advanced Plugins
Forms With Ajax And Advanced Plugins
 
Html forms
Html formsHtml forms
Html forms
 
9780538745840 ppt ch04
9780538745840 ppt ch049780538745840 ppt ch04
9780538745840 ppt ch04
 
331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheet331592291-HTML-and-Cascading style sheet
331592291-HTML-and-Cascading style sheet
 
Html5ppt
Html5pptHtml5ppt
Html5ppt
 
New Form Element in HTML5
New Form Element in HTML5New Form Element in HTML5
New Form Element in HTML5
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5
 
FORMS IN PHP contains various tags and code
FORMS IN PHP contains various tags and codeFORMS IN PHP contains various tags and code
FORMS IN PHP contains various tags and code
 
Cgi
CgiCgi
Cgi
 
Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2Web Development Course: PHP lecture 2
Web Development Course: PHP lecture 2
 
Web I - 04 - Forms
Web I - 04 - FormsWeb I - 04 - Forms
Web I - 04 - Forms
 
Common gateway interface
Common gateway interfaceCommon gateway interface
Common gateway interface
 
web2_lec6.pdf
web2_lec6.pdfweb2_lec6.pdf
web2_lec6.pdf
 
Html5
Html5Html5
Html5
 
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...
 

Plus de Anne Lee

Week 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed databaseWeek 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed databaseAnne Lee
 
Data mining
Data miningData mining
Data miningAnne Lee
 
Data warehousing
Data warehousingData warehousing
Data warehousingAnne Lee
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recoveryAnne Lee
 
Database monitoring and performance management
Database monitoring and performance managementDatabase monitoring and performance management
Database monitoring and performance managementAnne Lee
 
transportation and assignment models
transportation and assignment modelstransportation and assignment models
transportation and assignment modelsAnne Lee
 
Database Security Slide Handout
Database Security Slide HandoutDatabase Security Slide Handout
Database Security Slide HandoutAnne Lee
 
Database Security Handout
Database Security HandoutDatabase Security Handout
Database Security HandoutAnne Lee
 
Database Security - IG
Database Security - IGDatabase Security - IG
Database Security - IGAnne Lee
 
03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTE03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTEAnne Lee
 
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLESAnne Lee
 
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATIONAnne Lee
 
Indexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDEIndexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDEAnne Lee
 
07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXESAnne Lee
 
07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXES07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXESAnne Lee
 
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulatWk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulatAnne Lee
 
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasaWk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasaAnne Lee
 
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalitaWk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalitaAnne Lee
 
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinigWk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinigAnne Lee
 
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1Anne Lee
 

Plus de Anne Lee (20)

Week 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed databaseWeek 17 slides 1 7 multidimensional, parallel, and distributed database
Week 17 slides 1 7 multidimensional, parallel, and distributed database
 
Data mining
Data miningData mining
Data mining
 
Data warehousing
Data warehousingData warehousing
Data warehousing
 
Database backup and recovery
Database backup and recoveryDatabase backup and recovery
Database backup and recovery
 
Database monitoring and performance management
Database monitoring and performance managementDatabase monitoring and performance management
Database monitoring and performance management
 
transportation and assignment models
transportation and assignment modelstransportation and assignment models
transportation and assignment models
 
Database Security Slide Handout
Database Security Slide HandoutDatabase Security Slide Handout
Database Security Slide Handout
 
Database Security Handout
Database Security HandoutDatabase Security Handout
Database Security Handout
 
Database Security - IG
Database Security - IGDatabase Security - IG
Database Security - IG
 
03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTE03 laboratory exercise 1 - WORKING WITH CTE
03 laboratory exercise 1 - WORKING WITH CTE
 
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
 
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
 
Indexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDEIndexes - INSTRUCTOR'S GUIDE
Indexes - INSTRUCTOR'S GUIDE
 
07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES07 ohp slides 1 - INDEXES
07 ohp slides 1 - INDEXES
 
07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXES07 ohp slide handout 1 - INDEXES
07 ohp slide handout 1 - INDEXES
 
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulatWk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
 
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasaWk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
 
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalitaWk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
 
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinigWk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
 
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
 

Dernier

Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistKHM Anwar
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Standkumarajju5765
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...APNIC
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Delhi Call girls
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$kojalkojal131
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.soniya singh
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663Call Girls Mumbai
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
horny (9316020077 ) Goa Call Girls Service by VIP Call Girls in Goa
horny (9316020077 ) Goa  Call Girls Service by VIP Call Girls in Goahorny (9316020077 ) Goa  Call Girls Service by VIP Call Girls in Goa
horny (9316020077 ) Goa Call Girls Service by VIP Call Girls in Goasexy call girls service in goa
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 

Dernier (20)

Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
SEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization SpecialistSEO Growth Program-Digital optimization Specialist
SEO Growth Program-Digital optimization Specialist
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
Best VIP Call Girls Noida Sector 75 Call Me: 8448380779
 
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
Call Girls Dubai Prolapsed O525547819 Call Girls In Dubai Princes$
 
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Green Park Escort Service Delhi N.C.R.
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
horny (9316020077 ) Goa Call Girls Service by VIP Call Girls in Goa
horny (9316020077 ) Goa  Call Girls Service by VIP Call Girls in Goahorny (9316020077 ) Goa  Call Girls Service by VIP Call Girls in Goa
horny (9316020077 ) Goa Call Girls Service by VIP Call Girls in Goa
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 

Php forms

  • 1. PHP Forms  GET and POST Method  Form Validation  Form Required Fields
  • 2. *Property of STI K0032 GET and POST Method A form data can be submitted using POST and GET method Both are used for same purpose but stand apart for some specifications GET and POST create an array which holds key/value pairs, where keys are the name of the form controls and values are the input data by the user
  • 3. *Property of STI K0032 GET and POST Method Both GET and POST method are treated as $_GET and $_POST in PHP These methods are superglobals, which means that they are always accessible, and they can be accessed using any function, class or file The $_GET method is an associative array of variables passed to the current script via the URL parameters
  • 4. *Property of STI K0032 GET and POST Method The $_POST method is an array of variables passed to the current script via the HTTP POST method In this method the information is transferred in a hidden manner A form that submits information is appended to the URL in the form of Query String which consists of name = value pairs in URL known as URL Encoding
  • 5. *Property of STI K0032 GET and POST Method This string contains user values/data, which are joined using equal (=) signs, separated by ampersand (&), and spaces are removed and replaced with plus (+) sign Name1=value1&name2=value2&name3=value3
  • 6. *Property of STI K0032 Get Method  http:/.www.example.com/index.html? name=mel@email.com&contact=09176543210  The code below is a client-side HTML form using method=“get” for user to fill the information
  • 7. *Property of STI K0032 Get Method  The code below is the server-side PHP script where, $_GET associative array is used to receive sent information from server end
  • 8. *Property of STI K0032 Post Method <form action="#" method="post"> .... </form> Below is a server-side PHP script where $_POST associative array is used to receive sent information at server end
  • 9. *Property of STI K0032 Form validation
  • 10. *Property of STI K0032 Form validation The form shown in Figure 6.1 consists of the following elements:  Name (required field - must contain letters and whitespaces)  E-mail (required field - must contain valid email address)  Website (optional field - if present, must contain valid website URL)  Comments (optional field - a multi-line text field)  Gender (required field - must select a radio button )
  • 11. *Property of STI K0032 Form Elements The Name, E-mail, Website are input elements Input elements, in particular, used text and submit values for its types attribute in order to create text fields and buttons The HTML code:
  • 12. *Property of STI K0032 Form Elements Radio button shows several options to the users from which the user may select one HTML Code:
  • 13. *Property of STI K0032 Form Elements The text area is typically a large text field with multiple rows The textarea element has three attributes – name, rows, and cols attribute HTML code:
  • 14. *Property of STI K0032 Form Elements  list element offers options from which the user might choose. A list can be created using the select element, within which is nested option elements for each option to appear  The select element has a name attribute giving the name for the browser to use when identifying the selection when the form is submitted  The option element has a value attribute for specifying what value to send when that option is selected, and it has a select attribute which allows the HTML to specify which option is initially selected. The code
  • 15. *Property of STI K0032 Form Elements  HTML Code:
  • 16. *Property of STI K0032 Form Element  The HTML code of the form element:  when the form is submitted, the form data is sent with method=”post”  So, the $_SERVER["PHP_SELF"] sends the submitted forms data to the page itself, instead of jumping to a different page
  • 17. *Property of STI K0032 Form Element  The $_SERVER["PHP_SELF"] is a super global variable that returns the filename of the currently executing script  Htmlspecialchars() function converts special characters to HTML entities  Cross-site scripting (XSS) is a type of computer security vulnerability typically found inWeb application
  • 18. *Property of STI K0032 Form Element  Example: test_form.php  if a user enters the normal URL in the address bar like "http://www.example.com/test_form.php", the above code will be translated to:
  • 19. *Property of STI K0032 Form Element  consider that if a user enters the following URL in the address bar: http://www.example.com/test_form.php/%22%3E %3Cscript%3Ealert('hacked')%3C/script%3E  will be translated to:
  • 20. *Property of STI K0032 Form Element be aware that any JavaScript code can be added inside the <script> tag A hacker can redirect the user to a file on another server, and that file can hold malicious code that can alter the global variables or submit the form to another address to save the user’s data
  • 21. *Property of STI K0032 how to avoid $_SERVER[“PHP_SELF”] exploit? The $_SERVER[“PHP_SELF”] exploit can be avoided using the htmlspecialchars() function if the user tries to exploit the PHP_SELF variable, it will result:
  • 22. *Property of STI K0032 Validate Form Data with PHP  The very first thing to do to validate form data with PHP is to pass all variables through PHP’s htmlspecialchars() function  For example:  With htmlspecialchars() function it would not be executed, because it would be saved as HTML escaped code like this:
  • 23. *Property of STI K0032 test_input()
  • 24. *Property of STI K0032 Form Required Fields  In the previous slide, all input fields were optional, meaning no required fields to be filled in by the user  Here is a simple PHP script that checks the name for empty input and throws an error message if the input is empty:
  • 25. *Property of STI K0032 Form Required Fields To display the error message in the HTML form (this will be generated if the user tries to submit the form without filling in the required fields) use the code below: