[eluser]sangprabo[/eluser]
I have modified the url_helper so MY_url_helper looks like this.
Code:
function redirect($uri = '', $method = 'location', $http_response_code = 302)
{
if ( ! preg_match('#^https?://#i', $uri))
{
$uri = site_url($uri);
}
switch($method)
{
case 'refresh' : header("Refresh:5;url=".$uri);
break;
default : header("Location: ".$uri, TRUE, $http_response_code);
break;
}
exit;
}
To use it
Code:
echo $this->parser->parse('static_page/success_message', $data, TRUE);
redirect($redirect_url, 'refresh');
I'm using it on my local machine. Nothing is wrong. The message is displayed correctly. And the page will be redirected within 5 seconds.
The problem is, when I upload my application to the server, it shows warning and the page is not redirected.
Code:
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /var/www/controllers/page.php:62)
Filename: helpers/MY_url_helper.php
Line Number: 29
My temporary solution is to create a meta tag
Code:
<meta http-equiv="Refresh" content="5; url={meta_redirect_url}" />
Do you guys have any better idea? Why can't I use the 'refresh' after echoing some lines of message? Thank you.