programming 7

profileShane0301
structure.pdf

<!DOCTYPE html> <html lang="en"> <head> <!--Name: Your name Filename: Blackboard User Name: XXXX Class Section: CTI.110.XXXX Purpose: --> <meta charset="utf-8" /> <title>L11 Event Form </title> <link href="lastname-lab11b-style.css" type="text/css" rel="stylesheet" /> <style> li {border: 3px solid #666cff; padding: 10px; margin-right:30px} </style> </head> <body> <div class="container"> <?php #Any variables used on the RIGHT side of an assignment statement must be populated before use! #In PHP the LEFT side can be defined at the same time used. NOT all languages allow this! //Use the $_POST superglobal to recieve information from the HTML form //The $_POST MUST match the name=xxx in the form input type. $name = $_POST['name']; $phone = $_POST['phone']; $adultTickets = $_POST['adultTickets']; $childTickets = $_POST['childTickets']; $date = $_POST['date']; $location = $_POST['location']; //Name of constants must follow the same rules as variable names, which means a valid constant name must starts with a letter or underscore, followed by any number of letters, numbers or underscores with one exception: the $ prefix is not required for constant names. By convention, constant names are usually written in uppercase letters separated by underscores. This is for their easy identification and differentiation from variables in the source code. #Declare and define named constants define ("TAX", 0.07); define ("ADULT_COST", 36.75); define ("CHILD_COST", 25.50); define ("MIN_FEE", 0.50); define ("MAX_FEE", 1.00); define ("ATTEND", 5); #Calculations for concert costs $totalTickets = $adultTickets + $childTickets;

if ($totalTickets <= ATTEND) { $fee = ($totalTickets * MAX_FEE); } else { $fee = ($totalTickets * MIN_FEE); } $subtotal = ($adultTickets * ADULT_COST) + ($childTickets * CHILD_COST); $salesTax = ($subtotal * TAX); $totalCost = $subtotal + $salesTax + $fee; //Print is also considered to be a function while echo is a language construct. You can use html tags in the print and echo statements. #Displays Final Report print ("<header><h1>Summary Ticket Cost for Concert</h1></header>"); print ("<p>Thank you <b>".$name."</b> at <b>".$phone. "</b>. Details of your total cost <b>$" .number_format($totalCost, 2). "</b> are shown below:</p>"); print("<ul><li>Adult Tickets: $adultTickets </li>"); print("<li>Child Tickets:" .$childTickets."</li>"); print("<li>Date: " .$date."</li>"); print("<li>Location: " .$location."</li>"); echo("<li>Sub-total: $".number_format($subtotal, 2)."</li>"); print("<li>Sales tax: $".number_format($salesTax, 2)."</li>"); print("<li>Fee: $".number_format($fee, 2)."</li></ul>"); echo("<ul><li><b>TOTAL:</b><b> $".number_format($totalCost, 2)." </b></li></ul>"); #Prints Finish print ("<h3>Thank you for using this program - Programmer is: lastname</h3>"); print ('<br><footer><a class="white" href="instructor-lab11b-form.html"> Return to Form Entry To Continue</a></footer>'); ?> </div> <!--closes container--> </body> </html>