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

PPT
Php forms
PPTX
PHP Form Validation Technique
DOCX
Php forms and validations by naveen kumar veligeti
PPTX
Form Handling using PHP
PDF
Making web forms using php
PPT
Chapter 07 php forms handling
ODP
Form Processing In Php
PPTX
Form using html and java script validation
Php forms
PHP Form Validation Technique
Php forms and validations by naveen kumar veligeti
Form Handling using PHP
Making web forms using php
Chapter 07 php forms handling
Form Processing In Php
Form using html and java script validation

What's hot (20)

PPTX
HTML Forms
PPTX
Form Validation in JavaScript
PPTX
html forms
PPTX
HTML Forms Tutorial
PDF
2. HTML forms
PPTX
Php and web forms
PPTX
Html form tag
PPT
Web forms and html lecture Number 4
PPTX
HTML Forms
PPTX
New Form Element in HTML5
PPTX
Forms in html5
PPSX
HTML5 - Forms
PPTX
Forms with html5 (1)
PPTX
html 5 new form attribute
PPTX
Web design - Working with forms in HTML
PDF
Html forms
PPTX
PDF
GET and POST in PHP
PPTX
Html forms
PPTX
Html forms
HTML Forms
Form Validation in JavaScript
html forms
HTML Forms Tutorial
2. HTML forms
Php and web forms
Html form tag
Web forms and html lecture Number 4
HTML Forms
New Form Element in HTML5
Forms in html5
HTML5 - Forms
Forms with html5 (1)
html 5 new form attribute
Web design - Working with forms in HTML
Html forms
GET and POST in PHP
Html forms
Html forms
Ad

Similar to PHP Making Web Forms (20)

PDF
4.4 PHP Session
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PPT
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PPTX
PHP SESSIONS & COOKIE.pptx
PDF
Web app development_cookies_sessions_14
PDF
PHP-Cookies-Sessions.pdf
PPTX
PHP 2
PPT
Session,cookies
PPTX
Session and cookies ,get and post methods
PPTX
Web Techniques like Cookies and Sessions
PPTX
PHP COOKIES AND SESSIONS
PDF
Form handling in php
PPSX
Sessions and cookies
PPTX
Session,cookies and get and post methods
PPT
Class 6 - PHP Web Programming
ODP
PHP BASIC PRESENTATION
PPTX
Php with mysql ppt
PPT
Lecture8 php page control by okello erick
ODP
Session Management & Cookies In Php
4.4 PHP Session
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
Lecture 11 - PHP - Part 5 - CookiesSessions.ppt
PHP SESSIONS & COOKIE.pptx
Web app development_cookies_sessions_14
PHP-Cookies-Sessions.pdf
PHP 2
Session,cookies
Session and cookies ,get and post methods
Web Techniques like Cookies and Sessions
PHP COOKIES AND SESSIONS
Form handling in php
Sessions and cookies
Session,cookies and get and post methods
Class 6 - PHP Web Programming
PHP BASIC PRESENTATION
Php with mysql ppt
Lecture8 php page control by okello erick
Session Management & Cookies In Php
Ad

More from krishnapriya Tadepalli (13)

PDF
Web content accessibility
PPTX
Data visualization tools
PDF
Drupal vs sitecore comparisons
PPT
Open Source Content Management Systems
PDF
My sql vs mongo
PDF
Comparisons Wiki vs CMS
PDF
Sending emails through PHP
PDF
Php introduction
PDF
Using advanced features in joomla
PDF
Presentation joomla-introduction
PDF
Language enabling
Web content accessibility
Data visualization tools
Drupal vs sitecore comparisons
Open Source Content Management Systems
My sql vs mongo
Comparisons Wiki vs CMS
Sending emails through PHP
Php introduction
Using advanced features in joomla
Presentation joomla-introduction
Language enabling

Recently uploaded (20)

PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Machine Learning_overview_presentation.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Electronic commerce courselecture one. Pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
A comparative analysis of optical character recognition models for extracting...
Chapter 3 Spatial Domain Image Processing.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
Programs and apps: productivity, graphics, security and other tools
Machine Learning_overview_presentation.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Network Security Unit 5.pdf for BCA BBA.
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx

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