我有一个允许用户在页面上发表评论的表单,但是他们需要登录/注册才能发布。
如果他们犯了错误(例如回复太短),他们会在登录后被告知('There was an error with you reply'...)。
但是,他们回复的内容丢失了,我该如何保存它以使其显示在表单中?
表单页面相当简单:
<?php if (isset($errors['reply_header'])) echo $errors['reply_header']; ?>
<form method="post" action="http://localhost/LOGIN/user/?action=reply">
<input type="hidden" name="auth_token" value="<?php echo $auth_token; ?>">
<input type="hidden" name="thread_id" value="<?php echo $id; ?>">
<!--rest of the form goes here, thread_id shows us which thread/page they are replying to-->
这提交到此页面:
# get the register/login controller:
require_once FORUM_ROOT . 'register/index.php'; // if session is not set, then ask for login
if (isset($_GET['action']) )
{
switch ($_GET['action'])
{
case 'new': # create a new thread...
require_once USER_ROOT . 'new_thread.php';
break;
case 'reply':
$_POST['action'] == 'Reply';
require_once USER_ROOT . 'thread_reply.php';
die();
break;
default: # show user page...
require_once USER_ROOT . 'main.html.php';
break;
}
}
我知道我可以在会话中保存表单的内容,但我应该把它放在哪里?