So I need to write a PHP script that computes the total cost of the ordered light bulbs and battery packs after adding 17.5 percent VAT. The program must inform the buyer of exactly what was ordered in a table, and what credit card was chosen to make payment.
Here is my code so far (it is a form with checkboxes and radio buttons to order light bulbs)
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<script>
function formSubmit() {
document.forms["myForm"].submit();
}
</script>
</head>
<body>
<form name="myForm" action="calc.php" method="get">
Name: <input type="text" name="fullname"><br>
<input type="checkbox" name="bulb" value="Bulb1"> Four 100-watt light bulbs for $2.39<br>
<input type="checkbox" name="bulb" value="Bulb2"> Eight 100-watt light bulbs for $4.29<br>
<input type="checkbox" name="bulb" value="Bulb3"> Four 100-watt long-life light bulbs for $3.95<br>
<input type="checkbox" name="bulb" value="Bulb3"> Eight 100-watt long-life light bulbs for $7.49<br>
Number of battery packs you would like for $10.42 each: <input type="text" name="batterypacks"><br>
<input type="radio" name="bulb" value="Bulb1"> Visa<br>
<input type="radio" name="bulb" value="Bulb1"> Mastercard<br>
<input type="radio" name="bulb" value="Bulb1"> American Express<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
1) calc.php is where I plan on working on the php code for the calculations. I'm stuck -- How do I write a php script that counts if a box has been checked, assigns it a numerical value, and adds it together?
2) Also, I created a text form for "Number of battery packs you would like for $10.42 each". Depending on the number the user types in, the php script must multiply that number by 10.42 and also include the total VAT onto that in a table.
3) Lastly, to include the credit card type (the radio button choices) do I echo out what has been selected via the var name? (Amex, Visa, Master)
Aucun commentaire:
Enregistrer un commentaire