Presentation is loading. Please wait.

Presentation is loading. Please wait.

A little PHP. Enter the simple HTML code seen below.

Similar presentations


Presentation on theme: "A little PHP. Enter the simple HTML code seen below."— Presentation transcript:

1 A little PHP

2 Enter the simple HTML code seen below

3 Enter the simple HTML/PHP code seen below

4 Notes on PHP PHP code starts with PHP code can be placed with HTML tags, between HTML tags, etc. To have PHP add something to the HTML page, one uses the PHP instruction print PHP variables begin with a dollar sign Lines of PHP code end with a semicolon

5 Initializing PHP variables from form input <?php $UserName ="{$_POST['txtName']}"; ?> The code above takes the information from the txtName input box on the form that was sent over in the post operation and assigns it to the $UserName variable, which is later used in a print statement to print the user’s name.

6 Post both pages to the alpha Use FTP to put both pages on the alpha (alpha.lasalle.edu). PHP is an example of server-side scripting, it must be posted on a server (in particular, a PHP server) in order to work.

7 Simple Form

8 Result of clicking

9 Viewing source of “handler” does not show PHP code. The PHP code is executed on the server side, it prints results into the HTML code that contains it. Then that resulting HTML code is sent to the client.

10 Open the simple form in Visual Studio, add a select control/element. The right click and choose Properties.

11 Give the select element (drop-down list) a name, and add some items (text and values).

12 Drop-down list code in Source view

13 New PHP to handle drop-down list ?>

14 Updated form

15 Result of updated form handler Note that it’s the value and not the text that comes over.

16 Add a text input for the user to enter an email address, give it the name (and id) txtEmail

17 Add new PHP code to email message

18 The mail function The mail function has up to four arguments: –The address the message will be sent to –The subject of the message –The body of the message –Some extra stuff (including the return address and a formatting statement indicating that the email will use HTML format

19 PHP Concatenation $body = " Username: ". $UserName. " "; $body = $body. " Team Member: ". $TeamName. " "; In PHP the concatenation operator used to make longer strings from smaller strings is a period

20 For credit To get credit for this lab, show me the form (on the alpha), the HTML page that results from the handler, and the resulting email message.


Download ppt "A little PHP. Enter the simple HTML code seen below."

Similar presentations


Ads by Google