Welcome Guest, Not a member yet? Register   Sign In
How to Force Redirect After ECHO?
#11

[eluser]JanDoToDo[/eluser]
Gewa - It isn't possible for the page to be redirected using a PHP header after data is sent as the headers must come first. From php.net:
---------------------------------
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. e.g.

<html>
<?php
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: http://www.example.com/');
?>
---------------------------------

However, the only way this might be happening is using otput buffering or if you are using a meta tag to refresh the page after a certain time. But this doesnt seem to be what you are doing. Could you post the output to show the array is being posted? I also refer you to the CI documentation:

----------------
Note: In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers.
Note: For very fine grained control over headers, you should use the Output Library's set_header() function.
-------------------
#12

[eluser]Gewa[/eluser]
[quote author="JanDoToDo" date="1265919396"]Gewa - It isn't possible for the page to be redirected using a PHP header after data is sent as the headers must come first. From php.net:
---------------------------------
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. e.g.

<html>
<?php
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: http://www.example.com/');
?>
---------------------------------

However, the only way this might be happening is using otput buffering or if you are using a meta tag to refresh the page after a certain time. But this doesnt seem to be what you are doing. Could you post the output to show the array is being posted? I also refer you to the CI documentation:

----------------
Note: In order for this function to work it must be used before anything is outputted to the browser since it utilizes server headers.
Note: For very fine grained control over headers, you should use the Output Library's set_header() function.
-------------------[/quote]



IT'S POSSIBLE! Belive ME! I think noctrum's explanation is much more realistic.
I am thinking about rewiriting URL helper to make redirection with JavaScript...
#13

[eluser]Gewa[/eluser]
Solution :

Code:
function redirect($uri = '', $method = 'location')
    {
        switch($method)
        {
            case 'refresh2'    : header("Refresh:0;url=".site_url($uri));
                break;
            case 'refresh'    :

            echo '<META HTTP-EQUIV="refresh" CONTENT="0;URL='.site_url($uri).'">';
                break;
            default            : header("Location: ".site_url($uri));
                break;
        }
        exit;
    }

This helped me not to rewrite any peace of code in the app




Theme © iAndrew 2016 - Forum software by © MyBB