12.07.2015 Views

CHAPTER 6 - MetaLab

CHAPTER 6 - MetaLab

CHAPTER 6 - MetaLab

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>CHAPTER</strong> 6Form & PHP


Introduction• All of the following examples in this section willrequire two web pages.• The first page retrieves information posted bythe user, and the second sends the informationfrom the web server and scripting engine back tothe browser.• The first web page doesn’t have to contain anyPHP script at all.• Second page contains PHP codes embedded inHTML codes.


Getting Data from Form• An HTML form is a section of a documentcontaining normal content, markup, specialelements called controls (text field, checkboxes,radio buttons, drop down menu, text area), andlabels on those controls.• Users generally "complete" a form by modifyingits controls (entering text, selecting menu items,etc.), before submitting the form to an agent forprocessing (e.g., to a Web server, to a mailserver, etc.)


Getting Data from Form• To create a form using a pure HTML web page:Opening and closing tags.(< form >……< /form> )• Any controls such as text field , radio button etcthat are placed between the tags,automatically become part of the form that issent to the web server.


Getting Data from Form• Method action tells the server which page to goto once the user has checked a submit button onthe form• Example:…………….


Getting Data from Form• Attribute method controls the way that informationis sent to the server• There are two values for attribute method: get andpost• Example:or• In this course, most of our examples use post.


Getting Data from FormText Fields (text boxes)• Text fields are created using element• Setting type attribute to text


Getting Data from Formtextfield.html Enter your name here :textfield.php My name is :


Getting Data from Formtextfield.htmltextfield.phpMy name is hani


Getting Data from FormText area• use < textarea> tag instead of tagsbecause allow us to set the size andnumber of rows and columns of the control.


Getting Data from Formtextarea.htmlwhat are your favourite html editor?ultra editvisul interdevnote padcrimson editor


Getting Data from Formtextarea.phpMy favourite HTML editor are:


Getting Data from Formtextarea.htmltextarea.phpMy favourite HTML editor are :Ultra Edit Visual InterdevNote Pad Crimson Editor


Getting Data from FormCheckboxes• Checkbox is counted as an individual entity.• Users can have several checkboxes tickedaltogether, or none checked at all.• Checkboxes are created using tag,setting type attribute to checkbox.• Each checkbox controls was named and setindependently.


Getting Data from Formcheckboxes.htmlhave you ever use sybase before?Have you ever use sql server before?


Getting Data from Formcheckboxes.php


Getting Data from Formcheckboxes.htmlcheckboxes.phpOracleSQLServer


Getting Data from FormRadio buttons• Only one of the options / answers can beselected at a time.• Radio buttons are created using tag ,setting type attribute to radio.• Each radio buttons has a same name.


Getting Data from Formradiobutton.htmlc language,object oriented(java) .....can be considered as:programming language


Getting Data from Formradiobutton.php


Getting Data from Formradiobutton.htmlradiobutton.phpYou selected the answer : Programming Language


Getting Data from FormDropdown List boxes• Dropdown list boxes are created using and tags.• The tag that creates the list boxencloses a number of tags. the tags each contain the text thatcorresponds to an item on the dropdown list.


Getting Data from Formlistboxes.htmlwhat price of laptop are you looking to buy ?RM 3000- RM 3500RM 3500-RM 4000RM 4000-RM 4500


Getting Data from Formlistbox.php


Getting Data from Formlistboxes.htmllistbox.phpPrice Range: RM 3000- RM 3500


Inserting Data from Form IntoDatabase• The next topic shows how to insert data fromform into MySQL database.• The form has all type of form controls and thecomplete codes are shown inform_complete.html.• form_complete.html contains all HTML tags.• form_dbase.php contains PHP codes that sendthe data from form into MySQL database.


Inserting Data from Form IntoDatabaseform_complete.html


Inserting Data from Form IntoDatabaseform_dbase.php


Inserting Data from Form IntoDatabaseform_complete.html


Inserting Data from Form IntoDatabaseTableDatabaseDatabase content

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!