PHC- DarkSpade
Forum Veteran
pakumpleto or pacorrect naman po ng codes ko po mga ts pls
html file:
<!doctype html>
<head>
<title>Calculator</title>
</head>
<body>
<form method="post" action="calc.php" >
<p align="center"><b>Enter the first number :</b><br/><input type="text" name="num1" size="20"><br>
</p>
<p align="center"><select name = "function">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select></p>
<p align="center"><b>Enter the second number : </b><br/><input type="text" name="num2"size="20"></p>
<p align="center"><b>Answer : </b><br/>
</p>
<p align="center"><input type="submit" ></p>
</form>
</body>
php file:
<?php
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$func = $_POST['function'];
switch ($func) {
case "+":
$result = $_POST[num1] + $_POST[num2];
break;
case "-":
$result = $_POST[num1] - $_POST[num2];
break;
case "*":
$result = $_POST[num1] * $_POST[num2];
break;
case "/":
$result = $_POST[num1] / $_POST[num2];
}
$cal = new calculator();
if(isset($_POST['submit']))
{
$result = $cal->getresult($_POST['num1'],$_POST['num2'],$_POST['func']);
}echo $cal;
?>
html file:
<!doctype html>
<head>
<title>Calculator</title>
</head>
<body>
<form method="post" action="calc.php" >
<p align="center"><b>Enter the first number :</b><br/><input type="text" name="num1" size="20"><br>
</p>
<p align="center"><select name = "function">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select></p>
<p align="center"><b>Enter the second number : </b><br/><input type="text" name="num2"size="20"></p>
<p align="center"><b>Answer : </b><br/>
</p>
<p align="center"><input type="submit" ></p>
</form>
</body>
php file:
<?php
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$func = $_POST['function'];
switch ($func) {
case "+":
$result = $_POST[num1] + $_POST[num2];
break;
case "-":
$result = $_POST[num1] - $_POST[num2];
break;
case "*":
$result = $_POST[num1] * $_POST[num2];
break;
case "/":
$result = $_POST[num1] / $_POST[num2];
}
$cal = new calculator();
if(isset($_POST['submit']))
{
$result = $cal->getresult($_POST['num1'],$_POST['num2'],$_POST['func']);
}echo $cal;
?>
echo back mo nalng yung result