Wednesday, 18 December 2019

Ch-6 Using define function


you may use define() function for constant value. here below with green highlighted parts , teach you , How to use define() function in php.

You may update processedform.php by following highlighted(with green colour) coding.



<html>
<head>
<title>Form Proceed</title>
</head>
<body>
<h1>Anika Stationery</h1>
<h2>Order result</h2>
<?php
$book=$_POST['book'];
$pencil=$_POST['pencil'];
$pen=$_POST['pen'];
echo "order Proceed at ";
echo date("l jS \of F Y h:i:s A");
echo "Your Order List as follow:<br>";
echo "book: $book";
echo nl2br("\n pencil: $pencil");
echo "<br> pen: $pen<br>";
define('bookprice',20);
define('pencileprice',10);
define('penprice',5);
?>
<html>
<body >
<table border="1">
<tr>
<th>Product</th>
<th>Price Per Piece</th>
<th>Ordered Piece</th>
<th>Amount</th>
</tr>
<tr>
<td>Book</td>
<td>20</td>
<td><?php echo $book; ?></td>
<td><?php echo $cob=$book*bookprice; ?></td>
</tr>
<tr>
<td>Pencil</td>
<td>10</td>
<td><?php echo $pencil; ?></td>
<td><?php echo $copncl=$pencil*pencileprice; ?></td>
</tr>
<tr>
<td>Pen</td>
<td>5</td>
<td><?php echo $pen; ?></td>
<td><?php echo $copn=$pen*penprice; ?></td>

</tr>
<?php
$total=$cob+$copncl+$copn;
?>
<tr>

<td colspan="3">Sub Total Amount</td>
<td><?php echo $total; ?></td>

</tr>
<tr>
<?php
define('txt',0.10);

?>
<td colspan="3"> Total Amount with 10% tax</td>
<td><?php echo $total=$total*(1+ txt); ?></td>

</tr>
</table></body>
</html>
</body>
</html>


No comments:

Post a Comment

Ch-16 Associate Array