Here it is in the simplest form.
PHP Code:
<?
if(isset($_POST['submit'])){
$type = $_POST['type'];
$amount = $_POST['amount'];
$total = 12*$type*$amount;
$lowest = 12*15*$amount;
$save = $total-$lowest;
}
?>
<html>
<head>
<title>Energy Calc</title>
</head>
<body>
<?
if(isset($save)){
echo "<table>";
echo "<tr><td>You are using $amount $type watt bulbs. This is $total watts in a 12hr time frame.</td></tr>";
if($type != 15){
echo "<tr><td>If you used 15 watt bulbs, you would only be using $lowest watts! That is a $save watt difference!</td></tr>";
}
echo "</table>";
}
?>
<form method="post">
<table>
<tr><td colspan="2">What type of bulb do you have?</td></tr>
<tr><td colspan="2"><input type="radio" name="type" value="25" />25 Watt Energy Saver | <input type="radio" name="type" value="15" />15 Watt | <input type="radio" name="type" value="60" />60 Watt</td></tr>
<tr><td align="right"> How Many?</td><td><input id="amount" type="text" name="amount" /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="submit" id="submit" />
</table>
</form>
</body>
</head>
Bookmarks