eg-259:lecture18
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
eg-259:lecture18 [2012/03/20 08:05] – [Example – Popcorn Sales Receipt] eechris | eg-259:lecture18 [2013/03/08 18:04] (current) – [PHP for Web Applications] eechris | ||
---|---|---|---|
Line 2: | Line 2: | ||
====== PHP for Web Applications ====== | ====== PHP for Web Applications ====== | ||
- | **Contact Hour 21**: To be discussed | + | **Supplementary Material** |
+ | |||
+ | Provided for Reference. This material is no longer taught | ||
**Lecturer**: | **Lecturer**: | ||
Using PHP for web applications development. | Using PHP for web applications development. | ||
- | |||
Line 227: | Line 228: | ||
* If the query string has '' | * If the query string has '' | ||
- | * '' | + | * '' |
* Query matching will also turn check box group '' | * Query matching will also turn check box group '' | ||
Line 459: | Line 460: | ||
<code php> | <code php> | ||
< | < | ||
- | <!-- popcorn3.html - This describes | + | <!-- popcorn3.php - Processes |
+ | popcorn3.html | ||
+ | --> | ||
<html lang=" | <html lang=" | ||
< | < | ||
<meta charset=" | <meta charset=" | ||
- | < | + | < |
</ | </ | ||
< | < | ||
- | < | + | <?php |
- | | + | // Get form data values |
- | < | + | $unpop=$_POST["unpop"]; |
- | Sales </ | + | $caramel=$_POST["caramel"]; |
- | < | + | $caramelnut=$_POST[" |
- | <!-- Text widgets for the customer' | + | $toffeynut=$_POST["toffeynut"]; |
- | < | + | $name=$_POST[" |
- | <td> Buyer' | + | $street=$_POST["street"]; |
- | < | + | $city=$_POST["city"]; |
- | <input type = "text" name = " | + | $payment=$_POST[" |
- | | + | // If any of the quantities are blank, set them to zero |
- | </ | + | if($unpop=="" |
- | </tr> | + | $unpop=0; |
- | < | + | if($caramel=="" |
- | <td> Street Address: </td> | + | $caramel=0; |
- | < | + | if($caramelnut=="" |
- | <input type = "text" | + | $caramelnut=0; |
- | | + | if($toffeynut=="" |
- | </td> | + | $toffeynut=0; |
- | </tr> | + | // Compute the item costs and total cost |
- | < | + | $unpop_cost=3.0*$unpop; |
- | <td> City, State, Zip: </td> | + | $caramel_cost=3.5*$caramel; |
- | <td> | + | $caramelnut_cost=4.5*$caramelnut; |
- | < | + | $toffeynut_cost=5.0*$toffeynut; |
- | size = " | + | $total_price=$unpop_cost+$caramel_cost+$caramelnut_cost+$toffeynut_cost; |
- | | + | $total_items=$unpop+$caramel+$caramelnut+$toffeynut; |
- | | + | // Return the results to the browser in a table |
- | </table> | + | ?> |
- | <p /> | + | <h4> Customer: </h4> |
- | <table border = " | + | <?php |
- | <!-- First, the column headings --> | + | print("$name < |
- | < | + | ?> |
- | <th> Product </ | + | |
- | <th> Price </ | + | <p /> |
- | <th> Quantity </ | + | <table border = " |
- | </tr> | + | <caption> |
- | <!-- Now, the table data entries --> | + | |
- | < | + | </ |
- | <td> Unpopped Popcorn | + | |
- | <td> $3.00 </ | + | <th> Product </ |
- | < | + | < |
- | | + | <th> Quantity |
- | size = "3" min=" | + | |
- | | + | </tr> |
- | </ | + | < |
- | < | + | <td> Unpopped Popcorn </ |
- | <td> Caramel Popcorn | + | <td> $3.00 </ |
- | <td> $3.50 </ | + | < |
- | < | + | < |
- | | + | </ |
- | size = "3" | + | < |
- | | + | <td> Caramel Popcorn </ |
- | </ | + | <td> $3.50 </ |
- | < | + | < |
- | <td> Caramel Nut Popcorn | + | < |
- | <td> $4.50 </ | + | </ |
- | < | + | < |
- | | + | <td> Caramel Nut Popcorn </ |
- | size = "3" | + | <td> $4.50 </ |
- | | + | < |
- | </ | + | < |
- | < | + | </ |
- | <td> Toffey Nut Popcorn | + | < |
- | <td> $5.00 </ | + | <td> Toffey Nut Popcorn </ |
- | < | + | <td> $5.00 </ |
- | | + | < |
- | size = " | + | <td><?php printf(" |
- | | + | </tr> |
- | </tr> | + | </table> |
- | | + | <p /> |
- | | + | <p /> |
- | <!-- The radio buttons for the payment method --> | + | <?php |
- | < | + | print("You ordered $total_items popcorn items <br />"); |
- | <p> | + | printf("Your total bill is: $ %5.2f <br />", |
- | <input type = " | + | print("Your chosen method of payment is: $payment <br />"); |
- | checked = " | + | |
- | | + | |
- | | + | |
- | < | + | |
- | Master Card | + | |
- | | + | |
- | <input type = " | + | |
- | value = "discover" | + | |
- | Discover | + | |
- | | + | |
- | < | + | |
- | Check | + | |
- | | + | |
- | <br /> | + | |
- | <!-- The submit and reset buttons --> | + | |
- | <input type = "submit" | + | |
- | <input type = " | + | |
- | </p> | + | |
- | | + | |
</ | </ | ||
</ | </ | ||
- | |||
</ | </ | ||
* Output | * Output | ||
- | {{eg-259:l18-popcorn3-output.png|receipt for Popcorn | + | < |
+ | <h4> Customer: </ | ||
+ | < | ||
+ | <table border = " | ||
+ | < | ||
+ | < | ||
+ | <th> Product </ | ||
+ | <th> Unit Price </ | ||
+ | <th> Quantity Ordered </ | ||
+ | <th> Item Cost </ | ||
+ | </ | ||
+ | <tr align = " | ||
+ | <td> Unpopped Popcorn </ | ||
+ | <td> $3.00 </ | ||
+ | <td> 0 </ | ||
+ | <td> $ 0.00 </ | ||
+ | </ | ||
+ | <tr align = " | ||
+ | <td> Caramel | ||
+ | <td> $3.50 </ | ||
+ | <td> 0 </ | ||
+ | <td> $ 0.00 </ | ||
+ | </ | ||
+ | <tr align = " | ||
+ | <td> Caramel Nut Popcorn </ | ||
+ | <td> $4.50 </ | ||
+ | <td> 0 </ | ||
+ | <td> $ 0.00 </ | ||
+ | </ | ||
+ | <tr align = " | ||
+ | <td> Toffey Nut Popcorn </ | ||
+ | <td> $5.00 </ | ||
+ | <td> 0 </ | ||
+ | <td> $ 0.00 </ | ||
+ | </ | ||
+ | </ | ||
+ | <p /> <p /> | ||
+ | |||
+ | You ordered 0 popcorn items <br />Your total bill is: $ 0.00 <br />Your chosen method of payment is: <br /> | ||
+ | </ | ||
===== Files ===== | ===== Files ===== |
eg-259/lecture18.1332230741.txt.gz · Last modified: 2012/03/20 08:05 by eechris