I have a program that calculates a number from the database with the input of the user. I made it work fine, but my problem now is when I reset the page, the result is still there. Even if I use unset
in the variable of the result, it still stays there. Here is my code:
<?php
include 'dbconnect.php'
?>
<html>
<head>
</head>
<body>
<br>
<br>
<br>
<div align="center">
<form method="POST">
<?php
unset($res);
$fetch = "SELECT Valor FROM taxas WHERE Id = 5";
$send = mysqli_query($con, $fetch);
while ($row = mysqli_fetch_array($send)) {
$value = $row['Valor'];
}
echo $value;
if (isset($_POST['op'])) {
$num1 = $_POST['n1'];
}
$res = $value + $num1;
?>
*<input type="text" name="n1">
<button name="op"> = </button>
<?php
echo $res;
?>
</form>
</div>
</body>
</html>
if you need, code for the "dbconnect.php":
<?php
$place = "localhost";
$user = "root";
$pass = "";
$database = "teste2";
$con = mysqli_connect ($place, $user, $pass, $database);
if ($con->connect_error) {
die("Error: " . $con->connect_error);
}