Hi, i'll keep it short. i am trying to create a simple calculator. 2 files. (1 is html & the other is php). This is my caculator_form.html file's code :
<html>
<head>
<title>Calculation Form</title>
</head>
<body>
<form method="post" action="calculate.php">
<p>Value 1 : <input type="text" name="val1" size=10></p>
<p>Value 2 : <input type="text" name="val2" size=10></p>
<p>Type of calculation: <br>
<input type ="radio" name ="calc" value = "add">add<br>
<input type ="radio" name ="calc" value = "subtract">sub<br>
<input type ="radio" name ="calc" value = "multiply">multiply<BR>
<input type ="radio" name ="calc" value = "divide">divide<BR></p>
<input type="submit" name="submit" value="Calculate">
</form>
</body>
</html>
This is my second file file, calculator.php :
<html>
<head>
<title> calculation result</title>
</head>
<body>
<? if ($val1 == NULL || $val2 == NULL || $calc == NULL)
{ echo "<p>ERROR!!!!</p>"; }
if ($calc == "add") {
$result = $val1 + $val2;
}
else if ($calc == "subtract") {
$result = $val1 - $val2;
}
else if ($calc == "multiply") {
$result = $val1 * $val2;
}
else if ($calc == "divide") {
$result = $val1 / $val2;
}
?>
<? echo "<p>The result of the calculation = $result </p>"; ?>
</body>
</html>
i don't see any problem with this code. Futher more, it is from a php book which i am currently studying. I am unable to pass the values "val1" & "val2" from the html to the php file. What could the problem be? Could it be my configuration for php isn't correct? Thanks.

