[英]html refresh the page without sending form data again besides ajax
I have a form sending data via post to the page of itself. 我有一个通过邮寄将数据发送到自身页面的表单。 I want to refresh the page without sending form data again just like you go to the page initially.As far as I know I can use ajax to do so, but it is quite complicated. 我想刷新页面而无需再次发送表单数据,就像您刚进入页面时一样。据我所知,我可以使用ajax来执行此操作,但这非常复杂。 And, I am looking for simpler method to do so. 而且,我正在寻找更简单的方法来做到这一点。 I have searched overriding refresh but it is not possible. 我搜索了覆盖刷新,但这是不可能的。 So, do you have any methods refreshing the page without sending form data again besides ajax? 因此,除了ajax之外,您是否有其他方法可以刷新页面而无需再次发送表单数据?
my code of abc.php: 我的abc.php代码:
<html>
<body>
<?php
echo "<form action='abc.php' method='post'>";
if(isset($_POST["edit_u_name"])){
echo "<br><br>name: <input type='text' name='user_name' maxlength='20' value='" . $u_name . "'> <input type='submit' name='confirm_u_name' value='confirm'><input type='submit' name='cancel_u_name' value='cancel'>";
}
else
echo "<br><br>name: ". $u_name. " <input type='submit' name='edit_u_name' value='edit'>";
echo "</form>";
?>
</body>
</html>
When I press the edit button and then refresh, I want go to the page just like directly going to the page initially with sending data of edit button. 当我按下编辑按钮然后刷新时,我想转到页面,就像最初直接发送编辑按钮的数据进入页面一样。
Here you go 干得好
<!DOCTYPE html>
<?php
if(isset($_POST["u_name"])){
$u_name = $_POST["u_name"];
} else {
$u_name = '';
}
?>
<html>
<body>
<form action='abc.php' method='post'>
<span id="in" style="display: none">
<br>
<br>name: <input type='text' name='u_name' maxlength='20' value='<?php echo $u_name; ?>'>
<input type='submit' name='confirm_u_name' value='confirm'>
<input type='reset' name='cancel_u_name' value='cancel'>
</span>
<span id="ed">
<br>
<br>name: <?php echo ($u_name =='')?'--':$u_name; ?><input type='button' value="Edit"
onclick="document.getElementById('ed').style.display = 'none';document.getElementById('in').style.display = 'block';">
</span>
</form>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.