Download presentation
Presentation is loading. Please wait.
Published byBathsheba Price Modified over 9 years ago
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 (or echo) 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
GET versus POST
7
Send both pages to the alpha Test the pages on your local server. Verify that you have an account on the alpha (alpha.lasalle.edu). It should have your usual lasalle username. I believe the prescription for the passwords is the first five numbers of your SSN, an underscore, and then the first three letters of your username in small letters. (E.g. 12345_use). You can contact Ralph Romano (romano@lasalle.edu) if you are having trouble with your alpha account. (Write him from your lasalle account and tell him what you want tour password to be.)romano@lasalle.edu 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.
8
Simple Form
9
Result of clicking
10
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.
11
Return to the htm file and add the HTML code for a drop-down select. Add option tags between the select tags. The value of an option is what it will send to the server. The text between the two tags is what will show on the page.
12
New PHP to handle drop-down list
13
Updated form
14
Result of updated form handler Note that it’s the value and not the text that comes over.
15
Add a text/email input for the user to enter an email address, give it the name (and id) txtEmail
16
Add new PHP code to email message
17
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
18
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
19
Form with email
20
Resulting email
21
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.