I have a function called action_reg_user which insert data into the database. I tried doing the usual:
header('Location:page/param1/param2');
But it doesn't work
<?php
if(!empty($_POST)){
$username = $_POST['uname'];
$pword = md5($_POST['pword']);
print_r($_POST);
?>
<a href="reg_user/<?php echo $username; ?>/<?php echo $pword; ?>">Continue Registration</a>
<?php } ?>
Kohana doesn't generate the request headers until the final page is ready to go back to the browser. If you look in application/bootstrap.php, you'll see this near the very bottom:
echo Request::instance()
->execute()
->send_headers()
->response;
So what you'll want to do is get to the Request object and ask it to do the redirect for you. Usually, this should be done in your controller, not your view. In the controller, you can do $this->request->redirect('kohana/path'). If you insist on doing it in the view, you want Request::current()->redirect('kohana/path') to redirect the currently executing request in the hierarchical chain.
Be careful and notice those are NOT using URL::base in the path- Request::redirect handles that, so you just need to specify the controller/action/parameters.
Try to use
<?php
$this->request->redirect('url/to/redirect/');
Outside actions you can use this code
<?php
Request::initial()->redirect('url');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With