Looks pretty nice.... better than mine:
#!/usr/bin/php
<?php
function addGivenNumbers() {
/*
* Code created by AceLord
* © 2007-2008 [url="http://ghostblade.us/"]http://ghostblade.us/[/url]
* Contact via ghost@ghostblade.us, dxsurvives@gmail.com, or AceLord on MSN
* Good luck!
* Script made for PHP 4+
*/
$a = $_POST['number1'];
$b = $_POST['number2'];
$c = $_POST['operation'];
$d = $a + $b;
$e = $a - $b;
$f = $a * $b;
$g = $a / $b;
echo "<font color=\"red\"> Your answer is ";
if($c == add)
echo "$a + $b = $d";
if($c == sub)
echo "$a - $b = $e";
if($c == mul)
echo "$a × $b = $f";
if($c == div)
echo "$a ÷ $b = $g";
echo ".</font>";
}
if(isset($_POST['submitted'])) {
addGivenNumbers();
}
echo "<fieldset>
<legend>Calculator</legend>
<form action='<?php echo $_PHP_SELF; ?>' method='post'>
Numeral 1: <input type='text' name='number1' ><br />
Numeral 2: <input type='text' name='number2' ><br />
<br />Operation:
<select name='operation'>
<option name='calc' value='add' selected>Add (+)
<option name='calc' value='sub'>Subtract (-)
<option name='calc' value='mul'>Multiply (×)
<option name='calc' value='div'>Divide (÷)
</select>
<br /><br />
<input type='submit' id='submitted' name='submitted' value='Calculate' />
<input type='reset" value='Reset' />
</form>
</fieldset>";
?>
Edited by Mr. Matt, 24 December 2007 - 02:48 AM.
Changed SQL tags to code tags