【发布时间】:2011-05-15 23:28:18
【问题描述】:
我正在使用 PHP,并且正在制作一个表单发布到的操作页面。该页面检查错误,然后如果一切正常,它将它们重定向到已发布数据的页面。如果没有,我需要将它们重定向回错误所在的页面和 POST 变量。以下是其工作原理的要点。
HTML 看起来像这样...
<form name="example" action="action.php" method="POST">
<input type="text" name="one">
<input type="text" name="two">
<input type="text" name="three">
<input type="submit" value="Submit!">
</form>
action.php 看起来像这样...
if(error_check($_POST['one']) == true){
header('Location: form.php');
// Here is where I need the data to POST back to the form page.
} else {
// function to insert data into database
header('Location: posted.php');
}
如果出现错误,我需要将其 POST 回第一页。 我不能使用 GET,因为输入会太大。 如果可能的话,我不想使用 SESSION。 这可能吗?
【问题讨论】:
-
根据phpfreaks.com/forums/php-coding-help/…的一些帖子,您也许可以使用
header("Location: javascript:window.history.go(-1);");(未测试) -
嗯...如果需要,我也希望尝试添加错误消息。那是不允许的。