Page 1 of 1

Code Help, Please!!

Posted: Thu Apr 19, 2007 3:52 pm
by TheBrick33
I am just starting PHP, and have decided to make a very simple multifunction calculator. It has a pull-down menu for selection of operations, but whenever I choose anything other than Addition it doesn't show anything on my php page

HTML:

<html>
<title>Math Operations</title>
<head></head>

<body>

<form method = "POST" action = "Math2.php">

<input type = "text" name = "A" length = "15">

<select name = "prop">
<option value = "Addition">Addition
<option value = "Subtraction">Subtraction
<option value = "Multiplication">Multiplication
<option value = "Division">Division
<option value = "Modulus">Modulus
</select>

<input type = "text" name = "B" length = "15">

<input type = "submit" value = "Equate">

</form>
</body>
</html>



PHP:

<?php

$A = $_POST['A'];
$B = $_POST['B'];

$prop = $_POST['prop'];

if ($prop == 'Addition'){
$C = $A + $B;
}

if ($prop == 'Subtraction'){
$D = $A - $B;
}

echo $D;
echo $C;

?>



Any suggestions on how to fix my problem would be a lot of help.

Posted: Thu Apr 19, 2007 4:05 pm
by guitarlvr
I put your code into an html file and a php file and it worked fine. Nothing works other than addition and subtraction because there are no conditionals for them but the adding and subtracting worked fine.

Wayne