Tuesday 1 April 2014

HTML PROGRAM URGENT NEED HELP

Posted by Саша 02:16, under | No comments


HTML PROGRAM!!! URGENT NEED HELP!!? HTML PROGRAM!!! URGENT NEED HELP!!?

<?php

require_once('file_exceptions.php');

//
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
$address = $_POST['address'];


?>
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
$date = date('H:i, jS F');

echo '<p>Order processed at ';
echo $date;
echo '</p>';

echo '<p>Your order is as follows: </p>';

$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'
';

if( $totalqty == 0)
{
echo 'You did not order anything on the previous page!
';
}
else
{
if ( $tireqty>0 )
echo $tireqty.' tires
';
if ( $oilqty>0 )
echo $oilqty.' bottles of oil
';
if ( $sparkqty>0 )
echo $sparkqty.' spark plugs
';
}

$totalamount = 0.00;

define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);

$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;

$totalamount=number_format($totalamoun... 2, '.', ' ');

echo '<p>Total of order is '.$totalamount.'</p>';
echo '<p>Address to ship to is '.$address.'</p>';

$outputstring = $date."t".$tireqty." tires t".$oilqty." oilt"
.$sparkqty." spark plugst$".$totalamount
."t". $address."n";

// open file for appending
try
{
if (!($fp = @fopen("orders.txt", 'ab')))
throw new fileOpenException();

if (!flock($fp, LOCK_EX))
throw new fileLockException();

if (!fwrite($fp, $outputstring, strlen($outputstring)))
throw new fileWriteException();
flock($fp, LOCK_UN);
fclose($fp);
echo '<p>Order written.</p>';
}
catch (fileOpenException $foe)
{
echo '<p><strong>Orders file could not be opened. '
.'Please contact our webmaster for help.</strong></p>';
}
catch (Exception $e)
{
echo '<p><strong>Your order could not be processed at this time. '
.'Please try again later.</strong></p>';
}

?>
</body>
</html>



Can someone please tell me what this program is doing in detail (Explain each line).

I'm reviewing for my midterm, and would like to know! I would REALLY appreciate it if a kind soul could help me out!














0 коммент.:

Post a Comment