SlideShare a Scribd company logo
PHPFORMS
html formForms are a vital tool for the webmaster to receive information from the web surfer, such as: their name, email address, credit card, etc. A form will take input from the viewer and depending on your needs, you may store that data into a file, place an order, gather user statistics, register the person to your web forum, or maybe subscribe them to your weekly newsletter.
form text fieldsInput fields are going to be the meat of your form's sandwich. The <input> has a few attributes that you should be aware of.	type - Determines what kind of input field it will be. Possible choices are text, submit, and password.	name - Assigns a name to the given field so that you may reference it later.	size - Sets the horizontal width of the field. The unit of measurement is in blank spaces.maxlength - Dictates the maximum number of characters that can be entered.
Sample 1<form method="post" action="mailto:youremail@email.com"> Name: <input type="text" size="10" maxlength="40" name="name"> <br /> Password: <input type="password" size="10" maxlength="10" name="password"></form>
html form emailNow we will add the submit functionality to your form. Generally, the button should be the last item of your form and have its name attribute set to "Send" or "Submit". Name defines what the label of the button will be. Here is a list of important attributes of the submit:In addition to adding the submit button, we must also add a destination for this information and specify how we want it to travel to that place. Adding the following attributes to your <form> will do just this.	method - We will only be using the post functionality of method, which sends the data without displaying any of the information to the visitor.	action - Specifies the URL to send the data to. We will be sending our information to a fake email address.
Sample 2	<form method="post" action="mailto:youremail@email.com"> Name: <input type="text" size="10" maxlength="40" name="name"> <br /> Password: <input type="password" size="10" maxlength="10" name="password"><br /><input type="submit" value="Send"> </form>
html radio buttonsRadio buttons are a popular form of interaction. You may have seen them on quizzes, questionnaires, and other web sites that give the user a multiple choice question. Below are a couple attributes you should know that relate to the radio button.	value - specifies what will be sent if the user chooses this radio button. Only one value will be sent for a given group of radio buttons (see name for more information).	name - defines which set of radio buttons that it is a part of. Below we have 2 groups: shade and size.
Sample 3	<form method="post" action="mailto:youremail@email.com"> What kind of shirt are you wearing? <br /> Shade: <input type="radio" name="shade" value="dark">Dark <input type="radio" name="shade" value="light">Light <br /> Size:<input type="radio" name="size" value="small">Small <input type="radio" name="size" value="medium">Medium <input type="radio" name="size" value="large">Large <br /> <input type="submit" value="Email Myself"> </form>
html check boxesCheck boxes allow for multiple items to be selected for a certain group of choices. The check box's name and value attributes behave the same as a radio button.
Sample 4	<form method="post" action="mailto:youremail@email.com"> 	Select your favorite cartoon characters. <input type="checkbox" name="toon” value="Goofy">Goofy <input type="checkbox" name="toon" value="Donald">Donald <input type="checkbox" name="toon" value="Bugs">Bugs Bunny <input type="checkbox" name="toon" value="Scoob">Scooby Doo<input type="submit" value="Email Myself"> </form>
html drop down listsDrop down menues are created with the <select> and <option> tags. <select> is the list itself and each <option> is an available choice for the user.
Sample 5	<form method="post" action="mailto:youremail@email.com"> College Degree? <select name="degree"> <option>Choose One</option> 	<option>Some High School</option> 	<option>High School Degree</option> 	<option>Some College</option> 	<option>Bachelor's Degree</option> <option>Doctorate</option> <input type="submit" value="Email Yourself"> </select> </form>
html selection formsYet another type of form, a highlighted selection list. This form will post what the user highlights. Basically just another type of way to get input from the user.The size attribute selects how many options will be shown at once before needing to scroll, and the selected option tells the browser which choice to select by default.
Sample 6	<form method="post" action="mailto:youremail@email.com"> Musical Taste <select multiple name="music" size="4"> <option value="emo" selected>Emo</option> <option value="metal/rock" >Metal/Rock</option> <option value="hiphop" >Hip Hop</option> <option value="ska" >Ska</option> <option value="jazz" >Jazz</option> <option value="country" >Country</option> <option value="classical" >Classical</option> <option value="alternative" >Alternative</option> <option value="oldies" >Oldies</option> <option value="techno" >Techno</option> </select> <input type="submit" value="Email Yourself"> </form>
html upload formsAn upload form consists of three basic parts. The first being a hidden field. This hidden field does nothing more than limit the allowed file size of our uploaded file. The second part is the input field itself. In this field, the user has the option to type in the full local URL of the file or he/she may click the browse button to thumb through directory after directory. HTML codes this automatically when we place the type="file" attribute within the input tag.
Sample 7	<input type="hidden" name="MAX_FILE_SIZE" value="100" /> <input name="file" type="file" />
html text areasText areas serve as an input field for viewers to place their own comments onto. Forums and the like use text areas to post what you type onto their site using scripts. For this form, the text area is used as a way to write comments to somebody.Rows and columns need to be specified as attributes to the <textarea> tag. Rows are roughly 12pixels high, the same as in word programs and the value of the columns reflects how many characters wide the text area will be. i.e. The example below shows a text area 5 rows tall and 20 characters wide. Another attribute to be aware of is the wrap. Wrap has 3 values.wrap="off""virtual""physical"Virtual means that the viewer will see the words wrapping as they type their comments, but when the page is submitted to you, the web host, the document sent will not have wrapping words.Physical means that the text will appear both to you, the web host, and the viewer including any page breaks and additional spaces that may be inputed. The words come as they are.Off of course, turns off word wrapping within the text area. One ongoing line.
Sample 8	<form method="post" action="mailto:youremail@email.com"> <textarea rows="5" cols="20" wrap="physical" name="comments">Enter Comments Here </textarea> <input type="submit" value="Email Yourself"> </form>
using php with html formst is time to apply the knowledge you have obtained thus far and put it to real use. A very common application of PHP is to have an HTML form gather information from a website's visitor and then use PHP to do process that information. In this lesson we will simulate a small business's website that is implementing a very simple order form.
Sample 9<html><body> <h4>Tizag Art Supply Order Form</h4> <form> <select> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input type="text" /> <input type="submit" /> </form> </body></html>
Sample 10-Modified 9<html><body> <h4>Tizag Art Supply Order Form</h4> <form action="process.php" method="post"> <select name="item"> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input name="quantity" type="text" /> <input type="submit" /> </form> </body></html>
Php postWe want to get the "item" and "quantity" inputs that we have specified in our HTML form. Using an associative array (this term is explained in the array lesson), we can get this information from the $_POST associative array.The proper way to get this information would be to create two new variables, $item and $quantity and set them equal to the values that have been "posted".
Sample 11<html><body> <?php $quantity = $_POST['quantity']; $item = $_POST['item']; echo "You ordered ". $quantity . " " . $item . ".<br />"; echo "Thank you for ordering from Art Art Supplies!"; ?> </body></html>
Php get functionThe get method is different in that it passes the variables along to the "process.php" web page by appending them onto the end of the URL. The URL, after clicking submit, would have this added on to the end of it:"?item=##&quantity=##"The question mark "?" tells the browser that the following items are variables. Now that we changed the method of sending information on "order.html", we must change the "process.php" code to use the "$_GET" associative array.
Sample 12<html><body> <h4>Art ArtSupply Order Form</h4> <form action="process.php" method=“get"> <select name="item"> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input name="quantity" type="text" /> <input type="submit" /> </form> </body></html>

More Related Content

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

What's hot (20)

DOC
Handout2 formatting tags
PPTX
Form Handling using PHP
PPTX
Form Validation in JavaScript
PPT
Php forms
PPTX
Html forms
PPTX
3 php forms
PDF
5.1 html lec 5
PDF
4.1 html lec 4
DOCX
PHP HTML CSS Notes
PPT
Web forms and html lecture Number 4
PDF
2. HTML forms
PDF
html for beginners
PPTX
Forms in html5
PPT
Html5 new input attributes (@nzin4x)
PPTX
Form Validation
PPT
Form validation client side
DOC
Html introduction
PDF
Getting Information through HTML Forms
PDF
DOC
Handout1 intro to html
Handout2 formatting tags
Form Handling using PHP
Form Validation in JavaScript
Php forms
Html forms
3 php forms
5.1 html lec 5
4.1 html lec 4
PHP HTML CSS Notes
Web forms and html lecture Number 4
2. HTML forms
html for beginners
Forms in html5
Html5 new input attributes (@nzin4x)
Form Validation
Form validation client side
Html introduction
Getting Information through HTML Forms
Handout1 intro to html
Ad

Viewers also liked (19)

PDF
Deliver Files With PHP
DOCX
Script login form php
PPTX
PPT
PHP - Introduction to PHP Cookies and Sessions
PDF
Memphis php html form processing with php
PPTX
PHP Cookies and Sessions
PDF
PHP Files: An Introduction
PPT
PHP Cookies, Sessions and Authentication
PDF
ns-3: History and Future
PDF
Network Simulation NS3
DOC
Creating a Simple PHP and MySQL-Based Login System
PDF
Building Topology in NS3
PDF
Tutorial ns 3-tutorial-slides
PPTX
Client side scripting and server side scripting
PDF
ns-3 Tutorial
PDF
Client side scripting
PPSX
Php and MySQL
ODP
PHP Web Programming
PPT
Php Presentation
Deliver Files With PHP
Script login form php
PHP - Introduction to PHP Cookies and Sessions
Memphis php html form processing with php
PHP Cookies and Sessions
PHP Files: An Introduction
PHP Cookies, Sessions and Authentication
ns-3: History and Future
Network Simulation NS3
Creating a Simple PHP and MySQL-Based Login System
Building Topology in NS3
Tutorial ns 3-tutorial-slides
Client side scripting and server side scripting
ns-3 Tutorial
Client side scripting
Php and MySQL
PHP Web Programming
Php Presentation
Ad

Similar to Php Form (20)

PPT
Lecture 2 - Comm Lab: Web @ ITP
PPTX
Forms 2010
PPS
Quick Referance to WML
ODP
ODP
ODP
PPT
Intro Html
PPTX
03 handling requests
PPT
KMUTNB - Internet Programming 3/7
PPT
Lecture1 B Frames&Forms
PPT
Lect_html1
PPT
YL Intro html
PPT
Lecture 3 - Comm Lab: Web @ ITP
PPT
We9 Struts 2.0
PPT
Html Ppt
PPT
Lecture 6 - Comm Lab: Web @ ITP
Lecture 2 - Comm Lab: Web @ ITP
Forms 2010
Quick Referance to WML
Intro Html
03 handling requests
KMUTNB - Internet Programming 3/7
Lecture1 B Frames&Forms
Lect_html1
YL Intro html
Lecture 3 - Comm Lab: Web @ ITP
We9 Struts 2.0
Html Ppt
Lecture 6 - Comm Lab: Web @ ITP

More from lotlot (11)

PPTX
Pseudocode-Flowchart
PPTX
Form Script
PPTX
Mysql Aggregate
PPTX
Mysql Script
PPTX
Mysql
PPTX
Php Loop
PPTX
Php Condition Flow
PPTX
Php-Continuation
PPT
Hariyali - India
PPTX
The Province Of Davao Oriental
PPTX
Annual Review
Pseudocode-Flowchart
Form Script
Mysql Aggregate
Mysql Script
Mysql
Php Loop
Php Condition Flow
Php-Continuation
Hariyali - India
The Province Of Davao Oriental
Annual Review

Recently uploaded (20)

PDF
Dr. Enrique Segura Ense Group - A Self-Made Entrepreneur And Executive
PPTX
AI-assistance in Knowledge Collection and Curation supporting Safe and Sustai...
PPTX
ICG2025_ICG 6th steering committee 30-8-24.pptx
PDF
Traveri Digital Marketing Seminar 2025 by Corey and Jessica Perlman
PDF
MSPs in 10 Words - Created by US MSP Network
PPTX
5 Stages of group development guide.pptx
PDF
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
PDF
Reconciliation AND MEMORANDUM RECONCILATION
PDF
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
PPTX
Probability Distribution, binomial distribution, poisson distribution
PPT
Chapter four Project-Preparation material
PDF
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
PDF
Elevate Cleaning Efficiency Using Tallfly Hair Remover Roller Factory Expertise
PDF
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
PDF
Training And Development of Employee .pdf
PDF
A Brief Introduction About Julia Allison
PPTX
job Avenue by vinith.pptxvnbvnvnvbnvbnbmnbmbh
PDF
DOC-20250806-WA0002._20250806_112011_0000.pdf
PDF
Unit 1 Cost Accounting - Cost sheet
PDF
Types of control:Qualitative vs Quantitative
Dr. Enrique Segura Ense Group - A Self-Made Entrepreneur And Executive
AI-assistance in Knowledge Collection and Curation supporting Safe and Sustai...
ICG2025_ICG 6th steering committee 30-8-24.pptx
Traveri Digital Marketing Seminar 2025 by Corey and Jessica Perlman
MSPs in 10 Words - Created by US MSP Network
5 Stages of group development guide.pptx
SIMNET Inc – 2023’s Most Trusted IT Services & Solution Provider
Reconciliation AND MEMORANDUM RECONCILATION
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
Probability Distribution, binomial distribution, poisson distribution
Chapter four Project-Preparation material
Katrina Stoneking: Shaking Up the Alcohol Beverage Industry
Elevate Cleaning Efficiency Using Tallfly Hair Remover Roller Factory Expertise
pdfcoffee.com-opt-b1plus-sb-answers.pdfvi
Training And Development of Employee .pdf
A Brief Introduction About Julia Allison
job Avenue by vinith.pptxvnbvnvnvbnvbnbmnbmbh
DOC-20250806-WA0002._20250806_112011_0000.pdf
Unit 1 Cost Accounting - Cost sheet
Types of control:Qualitative vs Quantitative

Php Form

  • 2. html formForms are a vital tool for the webmaster to receive information from the web surfer, such as: their name, email address, credit card, etc. A form will take input from the viewer and depending on your needs, you may store that data into a file, place an order, gather user statistics, register the person to your web forum, or maybe subscribe them to your weekly newsletter.
  • 3. form text fieldsInput fields are going to be the meat of your form's sandwich. The <input> has a few attributes that you should be aware of. type - Determines what kind of input field it will be. Possible choices are text, submit, and password. name - Assigns a name to the given field so that you may reference it later. size - Sets the horizontal width of the field. The unit of measurement is in blank spaces.maxlength - Dictates the maximum number of characters that can be entered.
  • 4. Sample 1<form method="post" action="mailto:youremail@email.com"> Name: <input type="text" size="10" maxlength="40" name="name"> <br /> Password: <input type="password" size="10" maxlength="10" name="password"></form>
  • 5. html form emailNow we will add the submit functionality to your form. Generally, the button should be the last item of your form and have its name attribute set to "Send" or "Submit". Name defines what the label of the button will be. Here is a list of important attributes of the submit:In addition to adding the submit button, we must also add a destination for this information and specify how we want it to travel to that place. Adding the following attributes to your <form> will do just this. method - We will only be using the post functionality of method, which sends the data without displaying any of the information to the visitor. action - Specifies the URL to send the data to. We will be sending our information to a fake email address.
  • 6. Sample 2 <form method="post" action="mailto:youremail@email.com"> Name: <input type="text" size="10" maxlength="40" name="name"> <br /> Password: <input type="password" size="10" maxlength="10" name="password"><br /><input type="submit" value="Send"> </form>
  • 7. html radio buttonsRadio buttons are a popular form of interaction. You may have seen them on quizzes, questionnaires, and other web sites that give the user a multiple choice question. Below are a couple attributes you should know that relate to the radio button. value - specifies what will be sent if the user chooses this radio button. Only one value will be sent for a given group of radio buttons (see name for more information). name - defines which set of radio buttons that it is a part of. Below we have 2 groups: shade and size.
  • 8. Sample 3 <form method="post" action="mailto:youremail@email.com"> What kind of shirt are you wearing? <br /> Shade: <input type="radio" name="shade" value="dark">Dark <input type="radio" name="shade" value="light">Light <br /> Size:<input type="radio" name="size" value="small">Small <input type="radio" name="size" value="medium">Medium <input type="radio" name="size" value="large">Large <br /> <input type="submit" value="Email Myself"> </form>
  • 9. html check boxesCheck boxes allow for multiple items to be selected for a certain group of choices. The check box's name and value attributes behave the same as a radio button.
  • 10. Sample 4 <form method="post" action="mailto:youremail@email.com"> Select your favorite cartoon characters. <input type="checkbox" name="toon” value="Goofy">Goofy <input type="checkbox" name="toon" value="Donald">Donald <input type="checkbox" name="toon" value="Bugs">Bugs Bunny <input type="checkbox" name="toon" value="Scoob">Scooby Doo<input type="submit" value="Email Myself"> </form>
  • 11. html drop down listsDrop down menues are created with the <select> and <option> tags. <select> is the list itself and each <option> is an available choice for the user.
  • 12. Sample 5 <form method="post" action="mailto:youremail@email.com"> College Degree? <select name="degree"> <option>Choose One</option> <option>Some High School</option> <option>High School Degree</option> <option>Some College</option> <option>Bachelor's Degree</option> <option>Doctorate</option> <input type="submit" value="Email Yourself"> </select> </form>
  • 13. html selection formsYet another type of form, a highlighted selection list. This form will post what the user highlights. Basically just another type of way to get input from the user.The size attribute selects how many options will be shown at once before needing to scroll, and the selected option tells the browser which choice to select by default.
  • 14. Sample 6 <form method="post" action="mailto:youremail@email.com"> Musical Taste <select multiple name="music" size="4"> <option value="emo" selected>Emo</option> <option value="metal/rock" >Metal/Rock</option> <option value="hiphop" >Hip Hop</option> <option value="ska" >Ska</option> <option value="jazz" >Jazz</option> <option value="country" >Country</option> <option value="classical" >Classical</option> <option value="alternative" >Alternative</option> <option value="oldies" >Oldies</option> <option value="techno" >Techno</option> </select> <input type="submit" value="Email Yourself"> </form>
  • 15. html upload formsAn upload form consists of three basic parts. The first being a hidden field. This hidden field does nothing more than limit the allowed file size of our uploaded file. The second part is the input field itself. In this field, the user has the option to type in the full local URL of the file or he/she may click the browse button to thumb through directory after directory. HTML codes this automatically when we place the type="file" attribute within the input tag.
  • 16. Sample 7 <input type="hidden" name="MAX_FILE_SIZE" value="100" /> <input name="file" type="file" />
  • 17. html text areasText areas serve as an input field for viewers to place their own comments onto. Forums and the like use text areas to post what you type onto their site using scripts. For this form, the text area is used as a way to write comments to somebody.Rows and columns need to be specified as attributes to the <textarea> tag. Rows are roughly 12pixels high, the same as in word programs and the value of the columns reflects how many characters wide the text area will be. i.e. The example below shows a text area 5 rows tall and 20 characters wide. Another attribute to be aware of is the wrap. Wrap has 3 values.wrap="off""virtual""physical"Virtual means that the viewer will see the words wrapping as they type their comments, but when the page is submitted to you, the web host, the document sent will not have wrapping words.Physical means that the text will appear both to you, the web host, and the viewer including any page breaks and additional spaces that may be inputed. The words come as they are.Off of course, turns off word wrapping within the text area. One ongoing line.
  • 18. Sample 8 <form method="post" action="mailto:youremail@email.com"> <textarea rows="5" cols="20" wrap="physical" name="comments">Enter Comments Here </textarea> <input type="submit" value="Email Yourself"> </form>
  • 19. using php with html formst is time to apply the knowledge you have obtained thus far and put it to real use. A very common application of PHP is to have an HTML form gather information from a website's visitor and then use PHP to do process that information. In this lesson we will simulate a small business's website that is implementing a very simple order form.
  • 20. Sample 9<html><body> <h4>Tizag Art Supply Order Form</h4> <form> <select> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input type="text" /> <input type="submit" /> </form> </body></html>
  • 21. Sample 10-Modified 9<html><body> <h4>Tizag Art Supply Order Form</h4> <form action="process.php" method="post"> <select name="item"> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input name="quantity" type="text" /> <input type="submit" /> </form> </body></html>
  • 22. Php postWe want to get the "item" and "quantity" inputs that we have specified in our HTML form. Using an associative array (this term is explained in the array lesson), we can get this information from the $_POST associative array.The proper way to get this information would be to create two new variables, $item and $quantity and set them equal to the values that have been "posted".
  • 23. Sample 11<html><body> <?php $quantity = $_POST['quantity']; $item = $_POST['item']; echo "You ordered ". $quantity . " " . $item . ".<br />"; echo "Thank you for ordering from Art Art Supplies!"; ?> </body></html>
  • 24. Php get functionThe get method is different in that it passes the variables along to the "process.php" web page by appending them onto the end of the URL. The URL, after clicking submit, would have this added on to the end of it:"?item=##&quantity=##"The question mark "?" tells the browser that the following items are variables. Now that we changed the method of sending information on "order.html", we must change the "process.php" code to use the "$_GET" associative array.
  • 25. Sample 12<html><body> <h4>Art ArtSupply Order Form</h4> <form action="process.php" method=“get"> <select name="item"> <option>Paint</option> <option>Brushes</option> <option>Erasers</option> </select> Quantity: <input name="quantity" type="text" /> <input type="submit" /> </form> </body></html>