Welcome Guest, Not a member yet? Register   Sign In
Warning show up when using redirect($url, 'refresh');
#1

[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.


Messages In This Thread
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-28-2011, 09:46 PM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 01:34 AM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 02:34 AM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 02:41 AM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 02:49 AM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 03:15 AM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 04:18 AM
Warning show up when using redirect($url, 'refresh'); - by El Forum - 07-29-2011, 04:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB