我有一个简单的PHP表单,我根据表单字段输入进行计算。表单在同一页面上运行并计算图形然后显示。 但是,此时,一旦我提交并显示该值,则会在我刷新或再次返回页面时存储并显示该值。 如何清除这些脚本以便每次都重新运行脚本? (以下是我所拥有的):
<?php
$finalSavings == 0;
$value1 = $_POST['field1'];
$value2 = $_POST['field2'];
$value3 = $_POST['field3'];
$value4 = $_POST['field4'];
// Savings Calculations
$final1 = ($value1 * 10) / 100;
$final2 = ($value2 * 10) / 100;
$final3 = ($value3 * 10) / 100;
$final4 = ($value4 * 10) / 100;
// Final Savings Calculations
$finalSavings = $final1 + $final2 + $final3 + $final4;
if ($finalSavings > 0 ) {
echo $finalSavings;
}
?>
<form id="savingsCalculator" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" >
<input type="number" name="field1" id="field1">
<input type="number" name="field2" id="field2">
<input type="number" name="field3" id="field3">
<input type="number" name="field4" id="field4">
<input type="submit" value="Submit">
</form>