<?php
require("UPS.php");
require("USPS.php");

$dest_zip = $_POST['dest_zip'];
$weight = $_POST['weight'];

?>

<html>
<head>
<title>UPS/USPS Rate Quote Comparison</title>
<style type="text/css">
h1.ups {color: #330001}
h1.usps {color: #093a80}
.highlight {background-color:lightyellow;}
</style>
</head>
<body>

<?php 
$rate = ups($dest_zip,"03",$weight,'5','5','5');
$USPSPriorityRate = USPSPriorityRate($weight,$dest_zip);
$USPSParcelRate = USPSParcelRate($weight,$dest_zip);
$USPSFlatRate = number_format(9.80, 2, '.', '');

// Find the cheapest rate
$cheapestRate = min($rate,$USPSPriorityRate,$USPSParcelRate);
?>

<?php if (isset($_POST['foo'])) { ?>

<h1 class="ups"><span <?php if ($rate == $cheapestRate) { echo 'class="highlight"'; } ?>>$<?php echo $rate; ?> UPS 3 Day Ground</span></h1>
<h1 class="usps"><span <?php if ($USPSPriorityRate == $cheapestRate) { echo 'class="highlight"'; } ?>>$<?php echo $USPSPriorityRate; ?> Priority</span></h1>
<h1 class="usps"><span <?php if ($USPSParcelRate == $cheapestRate) { echo 'class="highlight"'; } ?>>$<?php echo $USPSParcelRate; ?> Parcel</span></h1>
<h1 class="usps"><span <?php if ($USPSFlatRate == $cheapestRate) { echo 'class="highlight"'; } ?>>$<?php echo $USPSFlatRate; ?> Priority Flat Rate Box</span></h1>

<?php } ?>


<form name="requestQuote" method="post" action="">
Destination Zip: 
<input type="text" name="dest_zip" value="<?php echo $dest_zip; ?>"><br />
<br />
Weight: 
<input type="text" name="weight" value="<?php echo $weight; ?>"><br />
<br />
<input type="hidden" name="foo" value="bar">
<input type="submit" value="Submit">
</form>

</body>
</html>