SlideShare a Scribd company logo
PHP Making Web
Forms
Krishna priya
April 20, 2011
C-DAC, Hyderabad
PHP GET and POST Methods
Before the browser sends the information, it encodes using a
scheme called URL encoding.
There are two ways the browser client can send information to the
web server.

The GET Method
The POST Method

The PHP $_GET and $_POST variables are
used to retrieve information from forms, like user input.
The GET Method
The GET method sends the encoded user information
appended to the page request. The page and the encoded
information are separated by the ? character.
http://www.test.com/index.htm?name1=value1&name2=v
alue2
The GET method is restricted to send upto 1024 characters
only.
Never use GET method if you have password or other
sensitive information to be sent to the server.
GET can't be used to send binary data, like images or word
documents, to the server.
The information is encoded as described in case of GET
method and put into a header called QUERY_STRING.
The POST Method
The POST method transfers information via HTTP headers.
The POST method does not have any restriction on data size to
be sent.
The POST method can be used to send ASCII as well as binary
data
The data sent by POST method goes through HTTP header so
security depends on HTTP protocol. By using Secure HTTP you can
make sure that your information is secure.
Differences
The main difference between GET and POST is how the form data is
passing. Both are used for passing form field values.
All the values which is submitted by the GET method will be appended to
the URL.
Where as POST method send the data with out appending the URL(hidden)
In GET Method we can bookmark the URLs where as in POST method its
not possible
In GET Method there is a limit for passing the data from one page to
another(ie 256 characters according to w3c standards)
But in POST we can send large amount of data
Compared to POST get is Faster
POST is more secure than get method
All the informations which is passed by GET method will be stored in
webserver(log file) but in POST we can not
Validating Form data
isset() determines whether a certain variable has already
been declared by PHP. It returns a boolean value true if
the variable has already been set, and false otherwise, or
if the variable is set to the value NULL.
Consider the following script:
1. if (isset($first_name)) {
2. print '$first_name is set';
3. }
This code snippet checks whether the variable
$first_name is defined. If $first_name is defined, isset()
returns true , which will display ' $first_name is set. ' If it
isn’t, no output is generated.
PHP Cookies

1.
2.
3.

Cookies are text files stored on the client computer and
they are kept of use tracking purpose. PHP transparently
supports HTTP cookies.
There are three steps involved in identifying returning
users:
Server script sends a set of cookies to the browser. For
example name, age, or identification number etc.
Browser stores this information on local machine for future
use.
When next time browser sends any request to web server
then it sends those cookies information to the server and
server uses that information to identify the user.
Cookies are usually set in an HTTP header. A PHP script
that sets a cookie might send headers that look something
like this:
setcookie(name, value, expire, path, domain,
security);
PHP Cookies
Name - This sets the name of the cookie and is stored in an environment
variable called HTTP_COOKIE_VARS. This variable is used while accessing
cookies.
Value -This sets the value of the named variable and is the content that
you actually want to store.
Expiry - This specify a future time in seconds since 00:00:00 GMT on 1st
Jan 1970. After this time cookie will become inaccessible. If this parameter
is not set then cookie will automatically expire when the Web Browser is
closed.
Path -This specifies the directories for which the cookie is valid. A single
forward slash character permits the cookie to be valid for all directories.
Domain - This can be used to specify the domain name in very large
domains and must contain at least two periods to be valid. All cookies are
only valid for the host and domain which created them.
Security - This can be set to 1 to specify that the cookie should only be
sent by secure transmission using HTTPS otherwise set to 0 which mean
cookie can be OK Date: Tue, 19 Apr
HTTP/1.1 200sent by regular HTTP. 2011 21:03:38 GMT

Server: Apache/1.3.9 (UNIX) PHP/4.0b3
Set-Cookie: name=xyz; expires=Friday, 22-Apr-11 22:03:38
GMT; path=/; domain=Yourdomian.com
Connection: close Content-Type: text/html
PHP Sessions
An alternative way to make data accessible across the
various pages of an entire website is to use a PHP Session.
PHP has a great set of functions that can achieve the same
results of Cookies and more without storing information on
the user's computer. PHP Sessions store the information on
the web server in a location that you chose in special files.
These files are connected to the user's web browser via the
server and a special ID called a "Session ID". This is nearly
99% flawless in operation and it is virtually invisible to the
user.
The location of the temporary file is determined by a
setting in the php.ini file called session.save_path. Bore
using any session variable make sure you have setup this
path.
Avoid Error PHP - Sessions
PHP Example: <?php
echo "Look at this nasty error below:<br />";
session_start();
?>
Error!
Warning: Cannot send session cookie - headers
already sent by (output started at
session_header_error/session_error.php:2) in
session_header_error/session_error.php on line 3
Warning: Cannot send session cache limiter headers already sent (output started at
session_header_error/session_error.php:2) in
session_header_error/session_error.php on line 3

PHP Example: <?php
session_start();
echo "Look at this nasty error
below:";
?>
Correct

More Related Content

What's hot (20)

HTML Forms
HTML FormsHTML Forms
HTML Forms
Ravinder Kamboj
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
Ravi Bhadauria
 
html forms
html formshtml forms
html forms
ikram niaz
 
HTML Forms Tutorial
HTML Forms TutorialHTML Forms Tutorial
HTML Forms Tutorial
ProdigyView
 
2. HTML forms
2. HTML forms2. HTML forms
2. HTML forms
Pavle Đorđević
 
Php and web forms
Php and web formsPhp and web forms
Php and web forms
sana mateen
 
Html form tag
Html form tagHtml form tag
Html form tag
shreyachougule
 
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
Mudasir Syed
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
Nisa Soomro
 
New Form Element in HTML5
New Form Element in HTML5New Form Element in HTML5
New Form Element in HTML5
Zahra Rezwana
 
Forms in html5
Forms in html5Forms in html5
Forms in html5
hrisi87
 
HTML5 - Forms
HTML5 - FormsHTML5 - Forms
HTML5 - Forms
tina1357
 
Forms with html5 (1)
Forms with html5 (1)Forms with html5 (1)
Forms with html5 (1)
Anada Kale
 
html 5 new form attribute
html 5 new form attributehtml 5 new form attribute
html 5 new form attribute
Priyanka Rasal
 
Web design - Working with forms in HTML
Web design - Working with forms in HTMLWeb design - Working with forms in HTML
Web design - Working with forms in HTML
Mustafa Kamel Mohammadi
 
Html forms
Html formsHtml forms
Html forms
eShikshak
 
Html forms
Html formsHtml forms
Html forms
Er. Nawaraj Bhandari
 
GET and POST in PHP
GET and POST in PHPGET and POST in PHP
GET and POST in PHP
Vineet Kumar Saini
 
Html forms
Html formsHtml forms
Html forms
nobel mujuji
 
Html forms
Html formsHtml forms
Html forms
Himanshu Pathak
 

Similar to PHP Making Web Forms (20)

Sessions n cookies
Sessions n cookiesSessions n cookies
Sessions n cookies
baabtra.com - No. 1 supplier of quality freshers
 
4.4 PHP Session
4.4 PHP Session4.4 PHP Session
4.4 PHP Session
Jalpesh Vasa
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
PHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptxPHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
Hassen Poreya
 
PHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfPHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
PHP 2
PHP 2PHP 2
PHP 2
Richa Goel
 
Session,cookies
Session,cookiesSession,cookies
Session,cookies
rkmourya511
 
Session and cookies ,get and post methods
Session and cookies ,get and post methodsSession and cookies ,get and post methods
Session and cookies ,get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
Web Techniques like Cookies and Sessions
Web Techniques like Cookies and SessionsWeb Techniques like Cookies and Sessions
Web Techniques like Cookies and Sessions
SonaliAbhang
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
Degu8
 
Form handling in php
Form handling in phpForm handling in php
Form handling in php
Fahad Khan
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
www.netgains.org
 
Session,cookies and get and post methods
Session,cookies  and get and post methodsSession,cookies  and get and post methods
Session,cookies and get and post methods
baabtra.com - No. 1 supplier of quality freshers
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
Ahmed Swilam
 
PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATION
krutitrivedi
 
Php with mysql ppt
Php with mysql pptPhp with mysql ppt
Php with mysql ppt
Rajamanickam Gomathijayam
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
okelloerick
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
Harit Kothari
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
SreejithVP7
 
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.pptLecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
pondypaiyan
 
PHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptxPHP SESSIONS & COOKIE.pptx
PHP SESSIONS & COOKIE.pptx
ShitalGhotekar
 
Web app development_cookies_sessions_14
Web app development_cookies_sessions_14Web app development_cookies_sessions_14
Web app development_cookies_sessions_14
Hassen Poreya
 
PHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfPHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdf
HumphreyOwuor1
 
Web Techniques like Cookies and Sessions
Web Techniques like Cookies and SessionsWeb Techniques like Cookies and Sessions
Web Techniques like Cookies and Sessions
SonaliAbhang
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
Degu8
 
Form handling in php
Form handling in phpForm handling in php
Form handling in php
Fahad Khan
 
Class 6 - PHP Web Programming
Class 6 - PHP Web ProgrammingClass 6 - PHP Web Programming
Class 6 - PHP Web Programming
Ahmed Swilam
 
PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATION
krutitrivedi
 
Lecture8 php page control by okello erick
Lecture8 php page control by okello erickLecture8 php page control by okello erick
Lecture8 php page control by okello erick
okelloerick
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
Harit Kothari
 
Ad

More from krishnapriya Tadepalli (13)

Web content accessibility
Web content accessibilityWeb content accessibility
Web content accessibility
krishnapriya Tadepalli
 
Data visualization tools
Data visualization toolsData visualization tools
Data visualization tools
krishnapriya Tadepalli
 
Drupal vs sitecore comparisons
Drupal vs sitecore comparisonsDrupal vs sitecore comparisons
Drupal vs sitecore comparisons
krishnapriya Tadepalli
 
Open Source Content Management Systems
Open Source Content Management SystemsOpen Source Content Management Systems
Open Source Content Management Systems
krishnapriya Tadepalli
 
My sql vs mongo
My sql vs mongoMy sql vs mongo
My sql vs mongo
krishnapriya Tadepalli
 
Node.js
Node.jsNode.js
Node.js
krishnapriya Tadepalli
 
Json
JsonJson
Json
krishnapriya Tadepalli
 
Comparisons Wiki vs CMS
Comparisons Wiki vs CMSComparisons Wiki vs CMS
Comparisons Wiki vs CMS
krishnapriya Tadepalli
 
Sending emails through PHP
Sending emails through PHPSending emails through PHP
Sending emails through PHP
krishnapriya Tadepalli
 
Php introduction
Php introductionPhp introduction
Php introduction
krishnapriya Tadepalli
 
Using advanced features in joomla
Using advanced features in joomlaUsing advanced features in joomla
Using advanced features in joomla
krishnapriya Tadepalli
 
Presentation joomla-introduction
Presentation joomla-introductionPresentation joomla-introduction
Presentation joomla-introduction
krishnapriya Tadepalli
 
Language enabling
Language enablingLanguage enabling
Language enabling
krishnapriya Tadepalli
 
Ad

Recently uploaded (20)

Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Lorenzo Miniero
 
Evaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical ContentEvaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical Content
Paul Groth
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
Fortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in CybersecurityFortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in Cybersecurity
VICTOR MAESTRE RAMIREZ
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Aaryan Kansari
 
Cyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptxCyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptx
Ghimire B.R.
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Let’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack CommunityLet’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack Community
SanjeetMishra29
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Palo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity FoundationPalo Alto Networks Cybersecurity Foundation
Palo Alto Networks Cybersecurity Foundation
VICTOR MAESTRE RAMIREZ
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Lorenzo Miniero
 
Evaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical ContentEvaluation Challenges in Using Generative AI for Science & Technical Content
Evaluation Challenges in Using Generative AI for Science & Technical Content
Paul Groth
 
Create Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent BuilderCreate Your First AI Agent with UiPath Agent Builder
Create Your First AI Agent with UiPath Agent Builder
DianaGray10
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
Fortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in CybersecurityFortinet Certified Associate in Cybersecurity
Fortinet Certified Associate in Cybersecurity
VICTOR MAESTRE RAMIREZ
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
ELNL2025 - Unlocking the Power of Sensitivity Labels - A Comprehensive Guide....
Jasper Oosterveld
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Contributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptxContributing to WordPress With & Without Code.pptx
Contributing to WordPress With & Without Code.pptx
Patrick Lumumba
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Agentic AI Explained: The Next Frontier of Autonomous Intelligence & Generati...
Aaryan Kansari
 
Cyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptxCyber Security Legal Framework in Nepal.pptx
Cyber Security Legal Framework in Nepal.pptx
Ghimire B.R.
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto CertificateCybersecurity Fundamentals: Apprentice - Palo Alto Certificate
Cybersecurity Fundamentals: Apprentice - Palo Alto Certificate
VICTOR MAESTRE RAMIREZ
 
Let’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack CommunityLet’s Get Slack Certified! 🚀- Slack Community
Let’s Get Slack Certified! 🚀- Slack Community
SanjeetMishra29
 

PHP Making Web Forms

  • 1. PHP Making Web Forms Krishna priya April 20, 2011 C-DAC, Hyderabad
  • 2. PHP GET and POST Methods Before the browser sends the information, it encodes using a scheme called URL encoding. There are two ways the browser client can send information to the web server. The GET Method The POST Method The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.
  • 3. The GET Method The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character. http://www.test.com/index.htm?name1=value1&name2=v alue2 The GET method is restricted to send upto 1024 characters only. Never use GET method if you have password or other sensitive information to be sent to the server. GET can't be used to send binary data, like images or word documents, to the server. The information is encoded as described in case of GET method and put into a header called QUERY_STRING.
  • 4. The POST Method The POST method transfers information via HTTP headers. The POST method does not have any restriction on data size to be sent. The POST method can be used to send ASCII as well as binary data The data sent by POST method goes through HTTP header so security depends on HTTP protocol. By using Secure HTTP you can make sure that your information is secure.
  • 5. Differences The main difference between GET and POST is how the form data is passing. Both are used for passing form field values. All the values which is submitted by the GET method will be appended to the URL. Where as POST method send the data with out appending the URL(hidden) In GET Method we can bookmark the URLs where as in POST method its not possible In GET Method there is a limit for passing the data from one page to another(ie 256 characters according to w3c standards) But in POST we can send large amount of data Compared to POST get is Faster POST is more secure than get method All the informations which is passed by GET method will be stored in webserver(log file) but in POST we can not
  • 6. Validating Form data isset() determines whether a certain variable has already been declared by PHP. It returns a boolean value true if the variable has already been set, and false otherwise, or if the variable is set to the value NULL. Consider the following script: 1. if (isset($first_name)) { 2. print '$first_name is set'; 3. } This code snippet checks whether the variable $first_name is defined. If $first_name is defined, isset() returns true , which will display ' $first_name is set. ' If it isn’t, no output is generated.
  • 7. PHP Cookies 1. 2. 3. Cookies are text files stored on the client computer and they are kept of use tracking purpose. PHP transparently supports HTTP cookies. There are three steps involved in identifying returning users: Server script sends a set of cookies to the browser. For example name, age, or identification number etc. Browser stores this information on local machine for future use. When next time browser sends any request to web server then it sends those cookies information to the server and server uses that information to identify the user. Cookies are usually set in an HTTP header. A PHP script that sets a cookie might send headers that look something like this: setcookie(name, value, expire, path, domain, security);
  • 8. PHP Cookies Name - This sets the name of the cookie and is stored in an environment variable called HTTP_COOKIE_VARS. This variable is used while accessing cookies. Value -This sets the value of the named variable and is the content that you actually want to store. Expiry - This specify a future time in seconds since 00:00:00 GMT on 1st Jan 1970. After this time cookie will become inaccessible. If this parameter is not set then cookie will automatically expire when the Web Browser is closed. Path -This specifies the directories for which the cookie is valid. A single forward slash character permits the cookie to be valid for all directories. Domain - This can be used to specify the domain name in very large domains and must contain at least two periods to be valid. All cookies are only valid for the host and domain which created them. Security - This can be set to 1 to specify that the cookie should only be sent by secure transmission using HTTPS otherwise set to 0 which mean cookie can be OK Date: Tue, 19 Apr HTTP/1.1 200sent by regular HTTP. 2011 21:03:38 GMT Server: Apache/1.3.9 (UNIX) PHP/4.0b3 Set-Cookie: name=xyz; expires=Friday, 22-Apr-11 22:03:38 GMT; path=/; domain=Yourdomian.com Connection: close Content-Type: text/html
  • 9. PHP Sessions An alternative way to make data accessible across the various pages of an entire website is to use a PHP Session. PHP has a great set of functions that can achieve the same results of Cookies and more without storing information on the user's computer. PHP Sessions store the information on the web server in a location that you chose in special files. These files are connected to the user's web browser via the server and a special ID called a "Session ID". This is nearly 99% flawless in operation and it is virtually invisible to the user. The location of the temporary file is determined by a setting in the php.ini file called session.save_path. Bore using any session variable make sure you have setup this path.
  • 10. Avoid Error PHP - Sessions PHP Example: <?php echo "Look at this nasty error below:<br />"; session_start(); ?> Error! Warning: Cannot send session cookie - headers already sent by (output started at session_header_error/session_error.php:2) in session_header_error/session_error.php on line 3 Warning: Cannot send session cache limiter headers already sent (output started at session_header_error/session_error.php:2) in session_header_error/session_error.php on line 3 PHP Example: <?php session_start(); echo "Look at this nasty error below:"; ?> Correct