Php 在kohana 3.3中提交表单后如何重定向用户
我想在用户将消息提交到数据库后重定向用户。提交查询执行,但重定向请求失败,并给出错误消息“ErrorException[致命错误]:调用未定义的方法request::instance()”,我不知道发生了什么。我使用的是Kohana 3.3.3。这是我的控制器,用于添加消息:Php 在kohana 3.3中提交表单后如何重定向用户,php,kohana-3.3,Php,Kohana 3.3,我想在用户将消息提交到数据库后重定向用户。提交查询执行,但重定向请求失败,并给出错误消息“ErrorException[致命错误]:调用未定义的方法request::instance()”,我不知道发生了什么。我使用的是Kohana 3.3.3。这是我的控制器,用于添加消息: public function action_add() { $messages = new Model_Message; $user_id = $this-
public function action_add()
{
$messages = new Model_Message;
$user_id = $this->request->param('id');
$this->template->content = View::factory('profile/message_form');
if (isset($_POST['content']))
{
$messages->add($user_id, (string) $_POST['content']);
$redirect = URL::site("messages/get_messages/$user_id");
Request::instance()->redirect($redirect);
}
}
您可以只使用以下选项:
$this->redirect($redirect, 302);
302表示临时重定向,301表示永久重定向。您可以使用以下命令:
$this->redirect($redirect, 302);
302表示临时重定向,301表示永久重定向。不客气。我想,您尝试的方式在v3.2中曾经使用过,但他们在v3.3中改变了它。不客气。我想,您尝试的方式在v3.2中曾经工作过,但他们在v3.3中改变了它。