我有一个指向检查$_POST['submit']
isset 的 php 控制器的链接。如果不是,它会显示一个表格。提交后,控制器(现在是$_POST['submit']
isset)会进行一些计算,包括 unset( $_POST
) 并以改变的状态重新显示表单。
这是我的问题。在表单以更改状态显示后,是否有办法在按下浏览器刷新按钮时以未更改的形式显示表单?
<?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>