I have a link to a php controller that checks if $_POST['submit'] isset. If not it displays a form. When submitted the controller (now that $_POST['submit'] isset) does some calculations including unset($_POST) and redisplays the form in an altered state.
Here's my problem. After the form is displayed in an altered state is there a way to display the form in its unaltered form when the browsers refresh button is pressed?
<?php /* Template Name: update_itn */ ?>
<?php
require ("../../../../wp-load.php");
require ("../include/constants.php");
$displayd3 = 'display:none';
if(isset($_POST['submit'])){
$displayd3 = 'display:block';
unset($_POST);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Update EMAILS</title>
<style>
textarea{
vertical-align:middle;
width:100%;
border:solid black 1px;
}
#d1{
text-align:center;
}
#d2{
padding:5%;
}
form{
text-align:center;
width:40%;
position:relative;
margin:0 auto;
}
span{
display:inline-block;
position:absolute;
left:-40%;
bottom:55%
}
button{
margin-top:10%;
font-size:1.75vw;
}
#d3{
color:purple;
text-align:center;
}
</style>
</head>
<body>
<div id='d1'>
<h1>SustainableWestonMA.org</h1>
<h2>Add Emails to Database</h2>
</div>
<div id='d2'>In the textbox below type or copy and paste email addresses you would like to add to the database.
Be sure to seperate emails with a comma. Emails are not verified so be sure they are correct.
Duplicate addresses will not be added.</div>
<div>
<form action='update_addEmails.php' method='POST' >
<span>Add Emails:</span><textarea rows='35' name='emails' id='emails' ></textarea> <br>
<button type='submit' name='submit' id='submit'>Update</button>
</form>
</div>
<div id='d3' style=<?php echo $displayd3;?>><h1>Emails have been added to the database</h1></div>
</body>
</html>
Using PRG pattern is the way to go.