Hi I'm trying to complete this assignment and I don't understand how this PHP thing works. I can't get the value of the check box to populate and I can't get the sales tax to calculate either. He is what I have so far:
<!DOCTYPE html>
<!-- testproblem.html
-->
<html lang = "en">
<head>
<title> Light Bulb Exercise </title>
<style type = "text/css">
td, th, table {border: thin solid black;}
</style>
</head>
<body>
<form action = "http://localhost:8888/mikeswork/testproblem.php" method = "post">
<h2> Light Bulb Convenient Store </h2>
<table>
<!-- Text widgets for the customer's name and address -->
<tr>
<td> Name: </td>
<td> <input type = "text" name = "name"
size = "30" />
</td>
</tr>
</table>
<p />
<table>
<!-- First, the column headings -->
<tr>
<th> Product </th>
<th> Price </th>
<th> Select One </th>
</tr>
<!-- Now, the table data entries -->
<tr>
<td> Four 25-Watt Light Bulbs</td>
<td> $2.39 </td>
<td><label>
<div align="center">
<input type="checkbox" name="checkbox1" value="$2.39"/> <br />
</div>
</label></td>
</tr>
<tr>
<td>Eight 25-Watt Light Bulbs</td>
<td> $4,29 </td>
<td><label>
<div align="center">
<input type="checkbox" name="checkbox2" value="$4.29" /> <br />
</div>
</label></td>
</tr>
<tr>
<td>Four 25-Watt Long Life Light Bulbs</td>
<td> $3.95 </td>
<td><label>
<div align="center">
<input type="checkbox" name="checkbox3" value="$3.95" /> <br />
</div>
</label></td>
</tr>
<tr>
<td>Eight 25-Watt Long Life Light Bulbs</td>
<td> $7.49 </td>
<td><label>
<div align="center">
<input type="checkbox" name="checkbox4" value="$7.49" /> <br />
</div>
</label></td>
</tr>
</table>
<p />
<!-- The radio buttons for the payment method -->
<h3> Payment Method</h3>
<input type = "radio" name = "payment" value = "Visa"
checked = "checked" />
Visa <br />
<input type = "radio" name = "payment" value = "Mastercard" />
Master Card <br />
<input type = "radio" name = "payment" value = "Discover" />
Discover <br />
<br />
<!-- The submit and reset buttons -->
<input type = "submit" value = "Submit Order" />
<input type = "reset" value = "Clear Order Form" />
</h3>
</form>
</body>
</html>
<!DOCTYPE html>
<!-- testproblem.php - Processes the form described in
testproblem.html
-->
<html lang = "en">
<head>
<title> Process the testproblem.html form </title>
<meta charset = "utf-8" />
<style type = "text/css">
td, th, table {border: thin solid black;}
</style>
</head>
<body>
<?php
// Get form data values
$checkbox1 = $_POST["checkbox1"];
$checkbox2 = $_POST["checkbox2"];
$checkbox3 = $_POST["checkbox3"];
$checkbox4 = $_POST["checkbox4"];
$name = $_POST["name"];
$payment = $_POST["payment"];
// If any of the quantities are blank, set them to zero
if ($checkbox1 == "") $checkbox1 = 0;
if ($checkbox2 == "") $checkbox2 = 0;
if ($checkbox3 == "") $checkbox3 = 0;
if ($checkbox4 == "") $checkbox4 = 0;
// Compute the item costs and total cost
$checkbox1_cost = 2.39 * $checkbox1;
$checkbox2_cost = 4.29 * $checkbox2;
$checkbox3_cost = 3.95 * $checkbox3;
$checkbox4_cost = 7.49 * $checkbox4;
$total_price = $checkbox1_cost + $checkbox2_cost + $checkbox3_cost + $checkbox4_cost;
$sales_tax = 1.062 * $total_price;
$total_items = $checkbox1 + $checkbox2 + $checkbox3 + $checkbox4;
// Return the results to the browser in a table
?>
<h4> Customer: </h4>
<?php
print ("$name");
?>
<p /> <p />
<table>
<caption> Order Information </caption>
<tr>
<th> Product </th>
<th> Unit Price </th>
<th> Quantity </th>
<th> Item Cost </th>
</tr>
<tr align = "center">
<td> Four 25-Watt Light Bulbs </td>
<td> $2.49 </td>
<td> <?php print ("$checkbox1"); ?> </td>
<td> <?php printf ("$ %4.2f", $checkbox1_cost); ?>
</td>
</tr>
<tr align = "center">
<td> Eight 25-Watt Light Bulbs </td>
<td> $4.29 </td>
<td> <?php print ("$checkbox2"); ?> </td>
<td> <?php printf ("$ %4.2f", $checkbox2_cost); ?>
</td>
</tr>
<tr align = "center">
<td> Four 25-Watt Long Life Light Bulbs </td>
<td> $3.95 </td>
<td> <?php print ("$checkbox3"); ?> </td>
<td> <?php printf ("$ %4.2f", $checkbox3_cost); ?>
</td>
</tr>
<tr align = "center">
<td> Eight 25-Watt Long Life Light Bulbs </td>
<td> $7.49 </td>
<td> <?php print ("$checkbox4"); ?> </td>
<td> <?php printf ("$ %4.2f", $checkbox4_cost); ?>
</td>
</tr>
</table>
<p /> <p />
<?php
print ("You ordered $total_items light bulbs items <br />");
printf ("Your total bill with the 6.2% sales tax is: $ %5.2f <br />", $sales_tax);
print ("Your chosen method of payment is:" $payment");
?>
</body>
</html>