这有点像一个菜鸟问题。我有一个控制器,从数据库更新记录,然后显示主页面。在更新方法中,
function update() {
$row = $this->db->update($tablename, $data);
if($row == 1) {
$this->index();
}
}
在这种情况下,视图返回到索引页面,但url仍然是localhost / controller / update。我应该使用重定向吗?
function update() {
$row = $this->db->update($tablename, $data);
if($row == 1) {
redirect(controller/index);
}
}
哪种方法是重定向页面的正确方法?谢谢。
答案 0 :(得分:2)
我建议使用redirect
方法。这样他们就不会意外地重新加载页面,并重新编辑行(我猜他们可以回击......)。
P.S。您需要controller/index
附近的引号。
redirect('controller/index');