I'm making a calculator to a webbsite. I have my php and html code on the same file but need to put them in separate files (a requirement for my course). I have tried using <form action = "cal.php">
, and even though it works it puts the result on a different page and not on the exact spot on the screen i want it to show up.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Something</title>
</head>
<body>
<form>
<input type="text" name="num1" placeholder="Tal 1">
<input type="text" name="num2" placeholder="Tal 2">
<select name="operator"><!-- used to choose which operator to calculate with from the php code -->
<option>Operation One</option> <!-- add -->
<option>Operation Two</option> <!-- sub -->
</select>
<br>
<button type="submit" name="submit" value="submit">Calculate </button>
</form>
<p>Result: </p>
<!-- php code -->
</body>
</html>
If i have the code on the same file i get the answer on the same page and exactly after "Result:", but when i separate them the answer prints out on a new blank page and in the corner. How do I get the same effect as if they were on the same file?
</div>