This is kinda a noob question. I have a controller that update record from a database, and then display the main page. In the update method,
function update() {
$row = $this->db->update($tablename, $data);
if($row == 1) {
$this->index();
}
}
In this case, the view goes back to the index page, but the url is still localhost/controller/update. Should I use redirect instead?
function update() {
$row = $this->db->update($tablename, $data);
if($row == 1) {
redirect(controller/index);
}
}
Which method is the correct way of redirecting pages? Thank you.
I'd suggest using the redirect
method. That way they can't accidently reload the page, and re-edit the row (I guess they could hit back...).
PS You need quotes around controller/index
.
redirect('controller/index');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.