Welcome Guest, Not a member yet? Register   Sign In
'headers already sent'
#1

[eluser]Fr3aked0ut[/eluser]
Hi, on my login page, when the login success I'm trying to make 2 cookies then redirect the user to someplace.

When I'm doing it the output is the error: headers already sent, the problem that we all know..

I checked out about spaces before or after <?php or ?>, no spaces at all.


What shall I do? thanks.
#2

[eluser]pistolPete[/eluser]
Post your code.

Are you using the CI sessions class? Why are you setting two cookies?
Totally omit all php closing tags, maybe you missed some whitespaces.
Do you echo something from within your controller?
#3

[eluser]Fr3aked0ut[/eluser]
Code:
class Admin extends Controller
{
    var $output;
    var $url = array();

    function Admin()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->database();
    }

    function index($page, $page2 = '', $page3 = '')
    {

        $this->url['site'] = base_url();

        $query = $this->db->query('SELECT * FROM dev_system');
        $row = $query->row();
        $this->url['site_images'] = site_url("system/application/views/" . $row->skin .
            "/images");
        $this->url['admin_images'] = site_url("system/application/admin_view/" . $row->
            admin_skin . "/images");


        $url = array();
        $url['site'] = $this->url['site'];
        $output = '';
        $url['admin_images'] = $this->url['admin_images'];
        $output .= $this->load->admin_view('header', $url, true);
        $this->load->model('admin_mod', '', true);
        $page1 = $this->admin_mod->panel_Details();
        if ($page1 == 'login') {
            $array = array();
            $array['site'] = $url['site'];
            $array['message'] = '';
            $array['name'] = '';
            if (isset($_POST['submit'])) {
                $array['name'] = $_POST['username'];
                if (!$this->admin_mod->check_Login($_POST['username'], $_POST['password']))
                    $array['message'] = 'הפרטים שהקלדת אינם נכונים. אנא נסה שנית.';
                else {
                    $id = $this->admin_mod->get_member_details($this->input->post('username'), $this->
                        input->post('password'))->id;
                    $query = $this->db->query("SELECT * FROM dev_converge WHERE con_id = '{$id}'");
                    $con = $query->row();
                    $array['message'] = 'התחברת בהצלחה! אתה מועבר לפאנל..';
                    //$this->admin_mod->redirect('admin/index/dashboard/main', 1);
                    $this->admin_mod->redirect('admin/index/moving', 1);
                }
            }
            $array['admin_images'] = $this->url['admin_images'];
            $output .= $this->load->admin_view('admin_login', $array, true);
        } else {
            if ($page == '') {
                $page = 'dashboard';
            }
            $button = array();
            $row = array();
            $row['buttons'] = array('dashboard' => 'דף ראשי', 'system' => 'הגדרות', 'cats' =>
                'קטגוריות', 'posts' => 'פוסטים', 'pages' => 'ניהול דפים', 'appear' => 'מראה',
                'users' => 'משתמשים');
            $row['site'] = $url['site'];
            $row['page'] = $page;

            $row['member'] = $this->admin_mod->_member($_COOKIE['member_id']);
            $row['member'] = $row['member']->name;

            $row['sub'] = array('dashboard' => array(), 'system' => array('הגדרות כלליות' =>
                'main', ), 'cats' => array('ניהול קטגוריות' => 'main', 'הוספת קטגוריה' =>
                'add_cat', ), 'posts' => array('ניהול פוסטים' => 'main', 'כתיבת פוסט' =>
                'add_post', 'הגדרות פוסטים' => 'def_post', ), 'pages' => array('ניהול דפים' =>
                'main', 'הוספת דף' => 'add_page', 'הגדרות דפים' => 'def_page', ), 'appear' =>
                array('ניהול סקין אתר' => 'main', 'ניהול סקין בפאנל' => 'admin_skin', ), 'users' =>
                array('ניהול משתמשים' => 'main', 'הוספת משתמש' => 'add_user', 'קבוצות משתמשים' =>
                'groups', 'הוספת קבוצה' => 'add_g', ), );
            $row['admin_images'] = $this->url['admin_images'];
            $output .= $this->load->admin_view('panel_wrapper', $row, true);

            if ($page == 'logout')
            {
                $this->logout();
            }
            elseif( $page == 'moving' )
            {
                $this->moving();
            }
            else
            {
                include ('admin-pages/' . $page . '.php');
                $dev = new $page();
                $dev->admin = &$this;
                $dev->auto_run($page2, $page3);
                $output .= $dev->output;
            }
            $output .= $this->load->admin_view('panel_footer', '', true);
        }

        $output .= $this->load->admin_view('footer', '', true);

        $this->output->set_output($output);
    }
// some other methods
}
#4

[eluser]TheFuzzy0ne[/eluser]
Check the very start of the output source code. That should give you an indication of what to look for, be it a white space, or a string etc...
#5

[eluser]Fr3aked0ut[/eluser]
Nah, found nothing...

Actually, this is the error:
Quote:Message: Cannot modify header information - headers already sent by (output started at X/Visionize/system/application/controllers/admin.php:1)

The code i gave above is admin.php
#6

[eluser]jedd[/eluser]
[quote author="Fr3aked0ut" date="1236038385"]
The code i gave above is admin.php[/quote]

Does admin.php really not start with a <?php tag?
#7

[eluser]Fr3aked0ut[/eluser]
Of course it is..
#8

[eluser]pistolPete[/eluser]
How are you saving your files?
Try UTF-8 without BOM.
#9

[eluser]Fr3aked0ut[/eluser]
WOW you're huge man.
AWESOME!!!!!!!!!!

What does BOM mean?


Thanks alot!!!!! Smile
#10

[eluser]TheFuzzy0ne[/eluser]
http://en.wikipedia.org/wiki/Byte-order_mark




Theme © iAndrew 2016 - Forum software by © MyBB