Hi all,
I am new to php and I have a problem that I am looking into it for 1 day and can't understand it please help.
here is my html code :
<html>
<head>
<title> Calculation Form </title>
</head>
<body>
<form action=calculate.php method="POST">
value one: <input type="text" name"val1" size=10 /><br />
value two: <input type="text" name"val2" size=10 /><br />
<p>Calculation:<br>
<input type="radio" name="calc" value="add"> add<br>
<input type="radio" name="calc" value="subtract"> subtract<br>
<input type="radio" name="calc" value="multiply"> multiply<br>
<input type="radio" name="calc" value="devide"> devide</p>
<p><input type="submit" name="submit" value="calculate"></p>
</form>
</body>
</html>
It calls the calculate.php
it has 2 text boxes and 4 radio buttons that 4 simple calculation funtions
here is my php code
<?php
if (isset($_POST['submit'])) {
$total=0;
$selected_radio = "";
$selected_radio = $_POST['calc'];
if ($selected_radio == 'add') {
$total= ($_POST['val1'] + $_POST['val2']);
}
else if ($selected_radio == 'subtract') {
$total= ($_POST['val1'] - $_POST['val2']);
}
else if ($selected_radio == 'mutiply') {
$total= ($_POST['val1'] * $_POST['val2']);
}
else if ($selected_radio == 'devide') {
$total= ($_POST['val1'] / $_POST['val2']);
}
echo $total;
}
?>
and I get result such as add0 subtract0 and so on ...
First of all, I have no idea where that 0 come from. I echoed every thing for testing purposes and every thing shows fine. I also can't get the values inside the text boxes by using ($_POST['val1'];)
Please help, this is so frustrating for me ...
Thanks a lot,