I am working on a project. For my project, it requires user to enter inflation rate and rate of return of investment. If the user didn't enter anything, it will have default values of 3 and 4 respectively. Then if the user entered whatever value, it will be the value. (if the user entered 0, it will still post the 0. I have tried the following code but the default values do not work. Thank you for your time.
<html> <p> <b>Expected rate of return for investment (%): </b> <input type="number" value="<?php echo $_POST['rinvestment'];?>" min = "0" placeholder= "4" name="rinvestment" /> </p> <p> <b>Inflation Rate (%): </b> <input type="number" value="<?php echo $_POST['inflation'];?>" min = "0" step = "0.1" name="inflation" placeholder= "3"/> </p> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['rinvestment'])){ $rinvestment=$_POST['rinvestment']; } else { $rinvestment = 4; } if (isset($_POST['inflation'])){ $inflation=$_POST['inflation']; } else { $inflation = 3; } } ?>
issetof aPOSTvariable without sending anyPOSTrequest?