SlideShare a Scribd company logo
1 of 27
Download to read offline
HTML
afm -INFO2301S1Y1314
FORMS
THE
Contents
 Relations between PHP and HTML forms
 Requirements for use of forms
 How form works
afm -INFO2301S1Y1314
The two important tasks in dynamic websites
I. Creating data
II. Processing Data
The relationships:
afm -INFO2301S1Y1314
Client-Server Interaction.
 Interaction between user and web application.
 Primary source of data (Client).
 Process data to cater business needs (records
keeping, financial report, application status, etc)
 HTML and Web scripting depend on each other to
form web application.
The importance of HTML forms
afm -INFO2301S1Y1314
 Knowledge in HTML.
 Strong foundation in Hypertext Markup Language is
a prerequisite.
 Knowing the HTML functions in the presentation
layer.
 Website design is central at HTML layer.
 Design and functionality should be balance in any
web application.
The importance of HTML forms
afm -INFO2301S1Y1314
The typical use of HTML forms
afm -INFO2301S1Y1314
 A form on a web page gathers input data from the user.
 The data the form controls varies e.g. buttons, text
fields, menus, etc.
 On the other hand the user's data is sent back to the
server where it is processed by web programming
languages, e.g. a PHP script
The functions of forms
afm -INFO2301S1Y1314
Example :
<html>
<form name:”fname” action =“input_dest.php” method=“post”>
<! - -
--- form inputs
- - >
</form>
<html>
 A form is an area that can contain form elements.
 Form elements are elements that allow the user to
enter information (like text fields, text area fields,
dropdown menus,radio buttons, checkboxes, etc.) in a
form.
 A form is defined with the <form> tag.
The functions of forms
afm -INFO2301S1Y1314
 An input form
 The most used form tag is the <input> tag.
 The type of input is specified with the type attribute.
 We will look at some of the most commonly used input
types.
 Text Field input
 Text fields are used when you want the user to type
letters, numbers, etc. in a form.
The functions of forms
afm -INFO2301S1Y1314
Example :
<form>
First name:
<input type="text" name="firstname"> <br>
Last name:
<input type="text" name="lastname">
</form>
 Radio Buttons
 Radio Buttons are used when you want the
user to select one of a limited number of
choices.
The functions of forms
afm -INFO2301S1Y1314
Example :
<form>
<input type="radio" name="sex“
value="male"> Male <br>
<input type="radio" name="sex" value="female">
Female
</form>
 Checkboxes
 Checkboxes are used when you want the user to
select one or more options of a limited number of
choices.
The functions of forms
afm -INFO2301S1Y1314
Example :
<form>
I have a bike: <input type="checkbox" name="vehicle"
value="Bike“> <br>
I have a car: <input type="checkbox" name="vehi cle"
value="Car“> <br>
I have an airplane: <input type="checkbox“ ame="vehicle"
value="Airplane
</form>
 Submit Buttons
 To be useful, a form will contain a submit button, which
the user can press to send the data to the server (or
whatever)
 Use an input element with attribute type="submit“.
 By default, the button has Submit Query written on it but
you can supply our own label using the value attribute.
The functions of forms
afm -INFO2301S1Y1314
Example :
<form>
<input type=“submit“ ></br>
<input type=“submit" value=“HANTAR" />
</form>
 The Form's Action Attribute and the Submit Button
 When the user clicks on the "Submit" button, the content of the form
is sent to the server.
 The form element has two attributes: action and method.
 The form's action attribute defines the name of the file to send the
content to.
 The file defined in the action attribute usually does something with the
received input.
The functions of forms
afm -INFO2301S1Y1314
Example :
<form>
name=“formName" action="html_form_submit.php“
method="get">
Username:
<input type="text" name="user">
<input type="submit" value=“submit">
</form>
 Reset button
 A form might contain a reset button, which the user
can press to clear the data s/he has typed
 Use an input element with attribute type="reset“.
 By default, the button has Reset written on it but
you can supply your own label using the value
attribute:
The functions of forms
afm -INFO2301S1Y1314
Example :
<form>
<input type="text" name="user">
<input type=“reset" value=“padam">
</form>
1. START with the HTML <form> tag
2. ACTION attribute of the <form> tag is the URL of
the PHP script that ill process the input data from the
form
3. METHOD on how to process the input data
i. GET (Default) = appends the form-data to the URL
in name/value pairs: RL?name=value&name=value
ii. POST = Sends the form-data as an HTTP post
transaction
4. CREATE the form with buttons, boxes, and others
using HTML tags and fields
5. SUBMIT button so that the form can be processed
6. END the form with the </form> tag. End the HTML
document with the </html> tag
Steps to make web forms
afm -INFO2301S1Y1314
<html>
<body>
<form name="input" action="html_form_action.php" method="get">
Type your first name:
<input type="text" name="FirstName" value="Mickey" size=“20”><br>
Type your last name:
<input type="text" name="LastName" value="Mouse" size=“20“><br>
<input type="radio" name="sex" value="male"> Male <br>
<input type="radio" name="sex" value="female"> Female
I have a bike: <input type="checkbox" name="vehicle" value="Bike“><br>
I have a car: <input type="checkbox" name="vehicle" value="Car"> <br>
<input type="submit" value="Submit">
</form>
<p>
If you click the "Submit" button, you will send your input to a new page called
html_form_action.php.
</p>
</body>
</html>
Steps to make web forms
afm -INFO2301S1Y1314
 When the user presses submit...
 When the submit button is pressed, the browser
arranges the data in name/value pairs
How a form works
afm -INFO2301S1Y1314
Example :
<form>
name=“formName" action="html_form_submit.php“
method="get">
Username:
<input type="text" name="username"> <-- user type mickey->
<input type="text" name=“surname"> <-- user type mouse->
<input type="submit" value=“submit">
</form>
 ..what happens in between the form & the server is ..
The data arranged in name/value pairs, behind the scenes
the browser also encodes the data using standard URL
encoding:
This replaces spaces, slashes and other chars that are not
allowed in URLs by their hexadecimal equivalents
 example 1: spaces are replaced by %20 (which may
display as '+'); slashes by %2F
Example 2: the user types Mickey and O Mouse into the
form The data is arranged and encoded as follows
firstname=Mickey&surname=O%20Mouse
How a form works
afm -INFO2301S1Y1314
 ..in the end at the server is ..
After the data is encoded, the browser creates an
HTTP request
 the command (method) is given by the method
attribute the URL is given by the action attribute if
method="get", the data is added to the end of the
URL after a question mark,
 e.g.: GET
process.php?firstname=Mickey&surname=Mouse
How a form works
afm -INFO2301S1Y1314
 an illustration..
How a form works
afm -INFO2301S1Y1314
 Notes on POST and GET methods
 Notes on GET:
 Appends form-data into the URL in name/value pairs
 The length of a URL is limited (about 3000 characters)
 Never use GET to send sensitive data! (will be visible in the
URL)
 Useful for form submissions where a user want to bookmark the
result
 GET is better for non-secure data, like query strings in Google
 Notes on POST:
 Appends form-data inside the body of the HTTP request (data is
not shown is in URL)
 Has no size limitations
 Form submissions with POST cannot be bookmarked
How a form works
afm -INFO2301S1Y1314
 Which method we need in form?
 GET
 The default method GET
 sends submitted data to the server by attaching it to the end of
the URL in ‘the query string’
 POST
 used if the processing of a form causes side effects, likethe
modification of a database, updating a shopping cart, or sending
an email message
 Sends submitted data to the server by bundling up the data and
put it into HTTP header message body
How a form works
afm -INFO2301S1Y1314
 PHP holds values from a form in 3 ways
1) The simple short style. Example :$name, $id
// Available if the PHP directive register_globals = on. As of
// PHP 4.2.0 the default value of register_globals = off.
// Using/relying on this method is not preferred.
2) The medium style. Example :$_GET[‘name’], $_POST[‘id’]
// Available since PHP 4.1.0
3) The long style. Example : $HTTP_GET_VARS[‘name’],
$HTTP_POST_VARS[‘id’]
// As of PHP 5.0.0, these long predefined variables can be
// disabled with the register_long_arrays directive.
How PHP communicate with HTML form
afm -INFO2301S1Y1314
How PHP communicate with HTML form
afm -INFO2301S1Y1314
 Example PHP codes on receiving ends..
<html>
<body>
<?php
// Medium style;
$name = $_GET['your_name'];
$phone = $_GET['your_phone'];
$email = $_GET['your_email_addr'];
$this_file_dir = $_SERVER['PHP_SELF'] ;
echo ‘You’ve registered as‘.$name.’<br>’;
echo ‘Your phone number is’.$phone.’<br>’;
echo ‘Your email’.$email.’<br>’;
echo ‘this php file directory/path is ‘. $this_file_dir;
?>
</body>
</html>
How PHP communicate with HTML form
afm -INFO2301S1Y1314
Quiz 1??
afm -INFO2301S1Y1314
HTML
afm -INFO2301S1Y1314
FORMS
THE

More Related Content

What's hot

Creating simple php contact form
Creating simple php contact formCreating simple php contact form
Creating simple php contact formDaniel Downs
 
Forms in html5
Forms in html5Forms in html5
Forms in html5hrisi87
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascriptambuj pathak
 
Web engineering - HTML Form
Web engineering -  HTML FormWeb engineering -  HTML Form
Web engineering - HTML FormNosheen Qamar
 
05 html-forms
05 html-forms05 html-forms
05 html-formsPalakshya
 
The Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsThe Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsVincent Chien
 
HTML5 Forms - KISS time - Fronteers
HTML5 Forms - KISS time - FronteersHTML5 Forms - KISS time - Fronteers
HTML5 Forms - KISS time - FronteersRobert Nyman
 
PHP Training in Ambala ! Batra Computer Centre
PHP Training in Ambala ! Batra Computer CentrePHP Training in Ambala ! Batra Computer Centre
PHP Training in Ambala ! Batra Computer Centrejatin batra
 
JavaScript Training in Ambala ! Batra Computer Centre
JavaScript Training in Ambala ! Batra Computer CentreJavaScript Training in Ambala ! Batra Computer Centre
JavaScript Training in Ambala ! Batra Computer Centrejatin batra
 
04. session 04 working withformsandframes
04. session 04   working withformsandframes04. session 04   working withformsandframes
04. session 04 working withformsandframesPhúc Đỗ
 
Tadhg Bowe - i18n: how can I rephrase that?
Tadhg Bowe - i18n: how can I rephrase that?Tadhg Bowe - i18n: how can I rephrase that?
Tadhg Bowe - i18n: how can I rephrase that?Mage Titans ES
 
PHP form tutorial
PHP form tutorialPHP form tutorial
PHP form tutorialPromb
 
Getting started-with-oracle-so a-iv
Getting started-with-oracle-so a-ivGetting started-with-oracle-so a-iv
Getting started-with-oracle-so a-ivAmit Sharma
 

What's hot (20)

Html 5 Forms
Html 5 FormsHtml 5 Forms
Html 5 Forms
 
Javascript
JavascriptJavascript
Javascript
 
Creating simple php contact form
Creating simple php contact formCreating simple php contact form
Creating simple php contact form
 
Forms in html5
Forms in html5Forms in html5
Forms in html5
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Web engineering - HTML Form
Web engineering -  HTML FormWeb engineering -  HTML Form
Web engineering - HTML Form
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
 
05 html-forms
05 html-forms05 html-forms
05 html-forms
 
The Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsThe Django Book - Chapter 7 forms
The Django Book - Chapter 7 forms
 
HTML5 Forms - KISS time - Fronteers
HTML5 Forms - KISS time - FronteersHTML5 Forms - KISS time - Fronteers
HTML5 Forms - KISS time - Fronteers
 
PHP Training in Ambala ! Batra Computer Centre
PHP Training in Ambala ! Batra Computer CentrePHP Training in Ambala ! Batra Computer Centre
PHP Training in Ambala ! Batra Computer Centre
 
JavaScript Training in Ambala ! Batra Computer Centre
JavaScript Training in Ambala ! Batra Computer CentreJavaScript Training in Ambala ! Batra Computer Centre
JavaScript Training in Ambala ! Batra Computer Centre
 
04. session 04 working withformsandframes
04. session 04   working withformsandframes04. session 04   working withformsandframes
04. session 04 working withformsandframes
 
Tadhg Bowe - i18n: how can I rephrase that?
Tadhg Bowe - i18n: how can I rephrase that?Tadhg Bowe - i18n: how can I rephrase that?
Tadhg Bowe - i18n: how can I rephrase that?
 
Html frames
Html framesHtml frames
Html frames
 
PHP form tutorial
PHP form tutorialPHP form tutorial
PHP form tutorial
 
Getting started-with-oracle-so a-iv
Getting started-with-oracle-so a-ivGetting started-with-oracle-so a-iv
Getting started-with-oracle-so a-iv
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Java script basic
Java script basicJava script basic
Java script basic
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 

Viewers also liked

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
 
PHP Forms PHP 05
PHP Forms PHP 05PHP Forms PHP 05
PHP Forms PHP 05Spy Seat
 
Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5Michael Girouard
 
Php creating forms
Php creating formsPhp creating forms
Php creating formsargusacademy
 
Forms and Databases in PHP
Forms and Databases in PHPForms and Databases in PHP
Forms and Databases in PHPMike Crabb
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web ServicesBruno Pedro
 
Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2Pablo Godel
 

Viewers also liked (9)

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
 
PHP Forms PHP 05
PHP Forms PHP 05PHP Forms PHP 05
PHP Forms PHP 05
 
Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5Creating And Consuming Web Services In Php 5
Creating And Consuming Web Services In Php 5
 
3 php forms
3 php forms3 php forms
3 php forms
 
Php forms
Php formsPhp forms
Php forms
 
Php creating forms
Php creating formsPhp creating forms
Php creating forms
 
Forms and Databases in PHP
Forms and Databases in PHPForms and Databases in PHP
Forms and Databases in PHP
 
PHP and Web Services
PHP and Web ServicesPHP and Web Services
PHP and Web Services
 
Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2Creating Mobile Apps With PHP & Symfony2
Creating Mobile Apps With PHP & Symfony2
 

Similar to 03 the htm_lforms (20)

Designing web pages html forms and input
Designing web pages html  forms and inputDesigning web pages html  forms and input
Designing web pages html forms and input
 
Html forms
Html formsHtml forms
Html forms
 
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 form tag
Html form tagHtml form tag
Html form tag
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validation
 
CSS_Forms.pdf
CSS_Forms.pdfCSS_Forms.pdf
CSS_Forms.pdf
 
html 5 new form attribute
html 5 new form attributehtml 5 new form attribute
html 5 new form attribute
 
Higher - HTML forms
Higher - HTML formsHigher - HTML forms
Higher - HTML forms
 
Html forms
Html formsHtml forms
Html forms
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Html basics 10 form
Html basics 10 formHtml basics 10 form
Html basics 10 form
 
Html Form Controls
Html Form ControlsHtml Form Controls
Html Form Controls
 
Html advanced-reference-guide for creating web forms
Html advanced-reference-guide for creating web formsHtml advanced-reference-guide for creating web forms
Html advanced-reference-guide for creating web forms
 
R12 MOAC AND PAYABLES
R12 MOAC AND PAYABLESR12 MOAC AND PAYABLES
R12 MOAC AND PAYABLES
 
Working with data.pptx
Working with data.pptxWorking with data.pptx
Working with data.pptx
 
Html forms
Html formsHtml forms
Html forms
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
HTML FORMS.pptx
HTML FORMS.pptxHTML FORMS.pptx
HTML FORMS.pptx
 
Lectures-web
Lectures-webLectures-web
Lectures-web
 
03 handling requests
03 handling requests03 handling requests
03 handling requests
 

More from IIUM

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhostIIUM
 
Chapter 2
Chapter 2Chapter 2
Chapter 2IIUM
 
Chapter 1
Chapter 1Chapter 1
Chapter 1IIUM
 
Kreydle internship-multimedia
Kreydle internship-multimediaKreydle internship-multimedia
Kreydle internship-multimediaIIUM
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblockIIUM
 
Chap2 practice key
Chap2 practice keyChap2 practice key
Chap2 practice keyIIUM
 
Group p1
Group p1Group p1
Group p1IIUM
 
Tutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seoTutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seoIIUM
 
Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009IIUM
 
Exercise on algo analysis answer
Exercise on algo analysis   answerExercise on algo analysis   answer
Exercise on algo analysis answerIIUM
 
Redo midterm
Redo midtermRedo midterm
Redo midtermIIUM
 
Heaps
HeapsHeaps
HeapsIIUM
 
Report format
Report formatReport format
Report formatIIUM
 
Edpuzzle guidelines
Edpuzzle guidelinesEdpuzzle guidelines
Edpuzzle guidelinesIIUM
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam PaperIIUM
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam PaperIIUM
 
Group assignment 1 s21516
Group assignment 1 s21516Group assignment 1 s21516
Group assignment 1 s21516IIUM
 
Avl tree-rotations
Avl tree-rotationsAvl tree-rotations
Avl tree-rotationsIIUM
 
Week12 graph
Week12   graph Week12   graph
Week12 graph IIUM
 
Vpn
VpnVpn
VpnIIUM
 

More from IIUM (20)

How to use_000webhost
How to use_000webhostHow to use_000webhost
How to use_000webhost
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Kreydle internship-multimedia
Kreydle internship-multimediaKreydle internship-multimedia
Kreydle internship-multimedia
 
03phpbldgblock
03phpbldgblock03phpbldgblock
03phpbldgblock
 
Chap2 practice key
Chap2 practice keyChap2 practice key
Chap2 practice key
 
Group p1
Group p1Group p1
Group p1
 
Tutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seoTutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seo
 
Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009
 
Exercise on algo analysis answer
Exercise on algo analysis   answerExercise on algo analysis   answer
Exercise on algo analysis answer
 
Redo midterm
Redo midtermRedo midterm
Redo midterm
 
Heaps
HeapsHeaps
Heaps
 
Report format
Report formatReport format
Report format
 
Edpuzzle guidelines
Edpuzzle guidelinesEdpuzzle guidelines
Edpuzzle guidelines
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam Paper
 
Final Exam Paper
Final Exam PaperFinal Exam Paper
Final Exam Paper
 
Group assignment 1 s21516
Group assignment 1 s21516Group assignment 1 s21516
Group assignment 1 s21516
 
Avl tree-rotations
Avl tree-rotationsAvl tree-rotations
Avl tree-rotations
 
Week12 graph
Week12   graph Week12   graph
Week12 graph
 
Vpn
VpnVpn
Vpn
 

Recently uploaded

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

03 the htm_lforms

  • 2. Contents  Relations between PHP and HTML forms  Requirements for use of forms  How form works afm -INFO2301S1Y1314
  • 3. The two important tasks in dynamic websites I. Creating data II. Processing Data The relationships: afm -INFO2301S1Y1314
  • 4. Client-Server Interaction.  Interaction between user and web application.  Primary source of data (Client).  Process data to cater business needs (records keeping, financial report, application status, etc)  HTML and Web scripting depend on each other to form web application. The importance of HTML forms afm -INFO2301S1Y1314
  • 5.  Knowledge in HTML.  Strong foundation in Hypertext Markup Language is a prerequisite.  Knowing the HTML functions in the presentation layer.  Website design is central at HTML layer.  Design and functionality should be balance in any web application. The importance of HTML forms afm -INFO2301S1Y1314
  • 6. The typical use of HTML forms afm -INFO2301S1Y1314
  • 7.  A form on a web page gathers input data from the user.  The data the form controls varies e.g. buttons, text fields, menus, etc.  On the other hand the user's data is sent back to the server where it is processed by web programming languages, e.g. a PHP script The functions of forms afm -INFO2301S1Y1314 Example : <html> <form name:”fname” action =“input_dest.php” method=“post”> <! - - --- form inputs - - > </form> <html>
  • 8.  A form is an area that can contain form elements.  Form elements are elements that allow the user to enter information (like text fields, text area fields, dropdown menus,radio buttons, checkboxes, etc.) in a form.  A form is defined with the <form> tag. The functions of forms afm -INFO2301S1Y1314
  • 9.  An input form  The most used form tag is the <input> tag.  The type of input is specified with the type attribute.  We will look at some of the most commonly used input types.  Text Field input  Text fields are used when you want the user to type letters, numbers, etc. in a form. The functions of forms afm -INFO2301S1Y1314 Example : <form> First name: <input type="text" name="firstname"> <br> Last name: <input type="text" name="lastname"> </form>
  • 10.  Radio Buttons  Radio Buttons are used when you want the user to select one of a limited number of choices. The functions of forms afm -INFO2301S1Y1314 Example : <form> <input type="radio" name="sex“ value="male"> Male <br> <input type="radio" name="sex" value="female"> Female </form>
  • 11.  Checkboxes  Checkboxes are used when you want the user to select one or more options of a limited number of choices. The functions of forms afm -INFO2301S1Y1314 Example : <form> I have a bike: <input type="checkbox" name="vehicle" value="Bike“> <br> I have a car: <input type="checkbox" name="vehi cle" value="Car“> <br> I have an airplane: <input type="checkbox“ ame="vehicle" value="Airplane </form>
  • 12.  Submit Buttons  To be useful, a form will contain a submit button, which the user can press to send the data to the server (or whatever)  Use an input element with attribute type="submit“.  By default, the button has Submit Query written on it but you can supply our own label using the value attribute. The functions of forms afm -INFO2301S1Y1314 Example : <form> <input type=“submit“ ></br> <input type=“submit" value=“HANTAR" /> </form>
  • 13.  The Form's Action Attribute and the Submit Button  When the user clicks on the "Submit" button, the content of the form is sent to the server.  The form element has two attributes: action and method.  The form's action attribute defines the name of the file to send the content to.  The file defined in the action attribute usually does something with the received input. The functions of forms afm -INFO2301S1Y1314 Example : <form> name=“formName" action="html_form_submit.php“ method="get"> Username: <input type="text" name="user"> <input type="submit" value=“submit"> </form>
  • 14.  Reset button  A form might contain a reset button, which the user can press to clear the data s/he has typed  Use an input element with attribute type="reset“.  By default, the button has Reset written on it but you can supply your own label using the value attribute: The functions of forms afm -INFO2301S1Y1314 Example : <form> <input type="text" name="user"> <input type=“reset" value=“padam"> </form>
  • 15. 1. START with the HTML <form> tag 2. ACTION attribute of the <form> tag is the URL of the PHP script that ill process the input data from the form 3. METHOD on how to process the input data i. GET (Default) = appends the form-data to the URL in name/value pairs: RL?name=value&name=value ii. POST = Sends the form-data as an HTTP post transaction 4. CREATE the form with buttons, boxes, and others using HTML tags and fields 5. SUBMIT button so that the form can be processed 6. END the form with the </form> tag. End the HTML document with the </html> tag Steps to make web forms afm -INFO2301S1Y1314
  • 16. <html> <body> <form name="input" action="html_form_action.php" method="get"> Type your first name: <input type="text" name="FirstName" value="Mickey" size=“20”><br> Type your last name: <input type="text" name="LastName" value="Mouse" size=“20“><br> <input type="radio" name="sex" value="male"> Male <br> <input type="radio" name="sex" value="female"> Female I have a bike: <input type="checkbox" name="vehicle" value="Bike“><br> I have a car: <input type="checkbox" name="vehicle" value="Car"> <br> <input type="submit" value="Submit"> </form> <p> If you click the "Submit" button, you will send your input to a new page called html_form_action.php. </p> </body> </html> Steps to make web forms afm -INFO2301S1Y1314
  • 17.  When the user presses submit...  When the submit button is pressed, the browser arranges the data in name/value pairs How a form works afm -INFO2301S1Y1314 Example : <form> name=“formName" action="html_form_submit.php“ method="get"> Username: <input type="text" name="username"> <-- user type mickey-> <input type="text" name=“surname"> <-- user type mouse-> <input type="submit" value=“submit"> </form>
  • 18.  ..what happens in between the form & the server is .. The data arranged in name/value pairs, behind the scenes the browser also encodes the data using standard URL encoding: This replaces spaces, slashes and other chars that are not allowed in URLs by their hexadecimal equivalents  example 1: spaces are replaced by %20 (which may display as '+'); slashes by %2F Example 2: the user types Mickey and O Mouse into the form The data is arranged and encoded as follows firstname=Mickey&surname=O%20Mouse How a form works afm -INFO2301S1Y1314
  • 19.  ..in the end at the server is .. After the data is encoded, the browser creates an HTTP request  the command (method) is given by the method attribute the URL is given by the action attribute if method="get", the data is added to the end of the URL after a question mark,  e.g.: GET process.php?firstname=Mickey&surname=Mouse How a form works afm -INFO2301S1Y1314
  • 20.  an illustration.. How a form works afm -INFO2301S1Y1314
  • 21.  Notes on POST and GET methods  Notes on GET:  Appends form-data into the URL in name/value pairs  The length of a URL is limited (about 3000 characters)  Never use GET to send sensitive data! (will be visible in the URL)  Useful for form submissions where a user want to bookmark the result  GET is better for non-secure data, like query strings in Google  Notes on POST:  Appends form-data inside the body of the HTTP request (data is not shown is in URL)  Has no size limitations  Form submissions with POST cannot be bookmarked How a form works afm -INFO2301S1Y1314
  • 22.  Which method we need in form?  GET  The default method GET  sends submitted data to the server by attaching it to the end of the URL in ‘the query string’  POST  used if the processing of a form causes side effects, likethe modification of a database, updating a shopping cart, or sending an email message  Sends submitted data to the server by bundling up the data and put it into HTTP header message body How a form works afm -INFO2301S1Y1314
  • 23.  PHP holds values from a form in 3 ways 1) The simple short style. Example :$name, $id // Available if the PHP directive register_globals = on. As of // PHP 4.2.0 the default value of register_globals = off. // Using/relying on this method is not preferred. 2) The medium style. Example :$_GET[‘name’], $_POST[‘id’] // Available since PHP 4.1.0 3) The long style. Example : $HTTP_GET_VARS[‘name’], $HTTP_POST_VARS[‘id’] // As of PHP 5.0.0, these long predefined variables can be // disabled with the register_long_arrays directive. How PHP communicate with HTML form afm -INFO2301S1Y1314
  • 24. How PHP communicate with HTML form afm -INFO2301S1Y1314
  • 25.  Example PHP codes on receiving ends.. <html> <body> <?php // Medium style; $name = $_GET['your_name']; $phone = $_GET['your_phone']; $email = $_GET['your_email_addr']; $this_file_dir = $_SERVER['PHP_SELF'] ; echo ‘You’ve registered as‘.$name.’<br>’; echo ‘Your phone number is’.$phone.’<br>’; echo ‘Your email’.$email.’<br>’; echo ‘this php file directory/path is ‘. $this_file_dir; ?> </body> </html> How PHP communicate with HTML form afm -INFO2301S1Y1314