Create an order.php page that will have a form, which takes in: a) Name (text) b
ID: 3766635 • Letter: C
Question
Create an order.php page that will have a form, which takes in:
a) Name (text)
b) Address (textarea)
c) 3 Items. Each item has 2 text input fields: ? Item 1 : Name and Price ? Item 2 : Name and Price ? Item 3 : Name and Price
d) Discount: (select tag: “5%; 10%; 15%”) Submit value as 5, 10, or 15.
e) Submit button (“Place Order”)
Upon submission, the data is passed to a page called bill.php which processes the order. All amounts must be formatted to display as proper Saudi Riyal values, with SAR letters and correct precision.
bill.php does the following:
Calculate Total: = “Item 1 Price” + “Item 2 Price” + “Item 3 Price”
Calculate Discount: = Passed Discount / 100 ex: 10/100
Calculate Discount Amount = Total * Discount
Calculate Total Bill: = Total – (Discount Amount)
Displays the Name
Displays the address, with all the html tags stripped out.
Displays items ordered, Name and Price Display Total price, Discount price, and the Discount Percent.
Display Total Bill.
Sample Output: Name:
Bob Smith Ship
To: 1 Main St. Toronto, Ontario Order:
SAR 10.99Radio SAR 25.49 Ethernet Cable
SAR 45.99 USB Key Summed Total:
SAR 84.47 Discount: (15%) SAR 12.38 Bill Total: SAR 72.10
Explanation / Answer
//Save the following code with order.php
order.php
----------------------------------------
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method="post" action="bill.php" name="orderform">
Name : <br><input type="text" name="name" /><br>
Address : <br><textarea name="addr"></textarea><br>
Order :<br>
<table>
<th></th><th><b>Item</b></th><th><b>Price</b></th>
<tr><td>Item1: </td><td><input type="text" name="item1" /></td><td><input type="text" name="price1" /></td></tr>
<tr><td>Item2: </td><td><input type="text" name="item2" /></td><td><input type="text" name="price2" /></td></tr>
<tr><td>Item3: </td><td><input type="text" name="item3" /></td><td><input type="text" name="price3" /></td></tr>
</table><br>
Discount:<select name="discount">
<option>5</option>
<option>10</option>
<option>15</option>
</select>
<br>
<br>
<input type="submit" value="place order">
</form>
</body>
</html>
------------------------------------------
bill.php
------------------------------------------
<html>
<body>
Welcome <?php
$total = $_POST["price1"]+$_POST["price2"]+$_POST["price3"];
$percent=$_POST["discount"];
$disco = $percent/100;
$disam = $disco*$total;
$bill = $total-$disam;
$name = $_POST["name"];
$addr =$_POST["addr"];
?><br>Name :<?php
echo $name;
?><br>Address :<?php
echo $addr;
?><br><?php
echo "Item1: ".$_POST["item1"]." Price1: SAR".$_POST["price1"];
?><br><?php
echo "Item2: ".$_POST["item2"]." Price2: SAR".$_POST["price2"];
?><br><?php
echo "Item3: ".$_POST["item3"]." Price3: SAR".$_POST["price3"];
?><br><?php
?><br>Total :SAR<?php
echo $total;
?><br>Discount :SAR<?php
echo $disco;
?><br>Discount Amount :SAR<?php
echo $disam;
?><br>Bill :SAR<?php
echo $bill;
?><br>Discount Percent:<?php
echo $percent."%";
?>
<br>
</body>
</html>
//run it in xammp or wamp servers.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.