So I got this code and I'm still learning and I don't know what might the problem be, and a question is it unsafe to do this way?
<?php
print_form();
if(isset($_POST['calculate'])){
process_form();
}
function process_form(){
switch($_POST){
case "addition":
print $_POST['operand1'] + $_POST['operand2'];
break;
case "subtraction":
break;
case "multiplication":
break;
case "division":
}
}
function print_form(){
print <<<HTML
<html>
<head><title>Learning Php</title></head>
<body>
<form method="POST" action="">
Operand 1: <input type="text" name="operand1"><br>
Operand 2: <input type="text" name="operand2"><br>
<select name="operation">
<option value="addition"> Addition </option>
<option value="subtraction"> Subtraction </option>
<option value="multiplication"> Multiplication </option>
<option value="division"> Division </option>
</select>
<input type="submit" name="calculate" value="calculate">
</form>
</body>
</html>
HTML;
}
?>
Is it just not doing process_form() or is it resetting the value of calculate when pressing the button ?