Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted.

Similar presentations


Presentation on theme: "CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted."— Presentation transcript:

1 CHAPTER 7 Form & PHP

2 Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted by the user, and the second sends the information from the web server and scripting engine back to the browser. The first web page doesn’t have to contain any PHP script at all. Second page contains PHP codes embedded in HTML codes.

3 Getting Data from Form An HTML form is a section of a document containing normal content, markup, special elements called controls (text field, checkboxes, radio buttons, drop down menu, text area), and labels on those controls. Users generally "complete" a form by modifying its controls (entering text, selecting menu items, etc.), before submitting the form to an agent for processing (e.g., to a Web server, to a mail server, etc.)

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

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

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

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

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

9 Getting Data from Form textfield.html textfield.php My name is hani

10 Getting Data from Form Text area use tag instead of tags because allow us to set the size and number of rows and columns of the control.

11 Getting Data from Form textarea.html what are your favourite html editor? ultra edit visul interdev note pad crimson editor

12 Getting Data from Form textarea.php My favourite HTML editor are:

13 Getting Data from Form textarea.html textarea.php My favourite HTML editor are :Ultra Edit Visual Interdev Note Pad Crimson Editor

14 Getting Data from Form Checkboxes Checkbox is counted as an individual entity. Users can have several checkboxes ticked altogether, or none checked at all. Checkboxes are created using tag, setting type attribute to checkbox. Each checkbox controls was named and set independently.

15 Getting Data from Form checkboxes.html have you ever use sybase before? Have you ever use oracle before? Have you ever use sql server before?

16 Getting Data from Form checkboxes.php <?php echo “$checkbox1 ”; echo “$checkbox2 ”; echo “$checkbox3 ”; ?>

17 Getting Data from Form checkboxes.html checkboxes.php Oracle SQLServer

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

19 Getting Data from Form radiobutton.html c language,object oriented(java).....can be considered as: networking programming language operating system

20 Getting Data from Form radiobutton.php <? php echo “you selected the answer :$radiobutton”; ?>

21 Getting Data from Form radiobutton.html radiobutton.php You selected the answer : Programming Language

22 Getting Data from Form Dropdown List boxes Dropdown list boxes are created using and tags. The tag that creates the list box encloses a number of tags. the tags each contain the text that corresponds to an item on the dropdown list.

23 Getting Data from Form listboxes.html what price of laptop are you looking to buy ? RM 3000- RM 3500 RM 3500-RM 4000 RM 4000-RM 4500

24 Getting Data from Form listbox.php <?php echo “Price Range : $price" ; ?>

25 Getting Data from Form listboxes.html listbox.php Price Range: RM 3000- RM 3500

26 Inserting Data from Form Into Database The next topic shows how to insert data from form into MySQL database. The form has all type of form controls and the complete codes are shown in form_complete.html. form_complete.html contains all HTML tags. form_dbase.php contains PHP codes that send the data from form into MySQL database.

27 Inserting Data from Form Into Database form_complete.html

28 Inserting Data from Form Into Database form_dbase.php

29 Inserting Data from Form Into Database form_complete.html

30 Inserting Data from Form Into Database Database content Table Database


Download ppt "CHAPTER 7 Form & PHP. Introduction All of the following examples in this section will require two web pages. The first page retrieves information posted."

Similar presentations


Ads by Google