I have made a very basic form using php that takes input and then displays it. Once I have typed my text in the input field and submitted, I reload the page. After reloading, my text is still being displayed when it should not have been displayed because of the if
conditional containing the isset()
function. Steps to verify my problem:
- Go here.
- Enter any thing in the input area and click submit.
- You should see your input displayed just below the input area.
- Refresh the page.
- You will still see your previously entered text below the input area.
- And this is exactly my problem. I want the form to refresh after refreshing the page.
<!DOCTYPE html>
<html>
<body>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]?>">
<input type="text" name="name">
<input type="submit">
</form>
<?php
if (isset($_POST["name"])){
echo $_POST["name"];
}
?>
</body>
</html>