php - Cannot modify header -
possible duplicate:
cannot modify header information, headers sent
headers sent php
i'm trying figure oui why when load controller i'm getting cannot modify header information error. when gets if statement redirects login controller doesn't redirect. loads message dashboard controller loaded.
<?php if ( ! defined('basepath')) exit('no direct script access allowed'); class dashboard extends ci_controller { public function index() { //config defaults start $msgboxmsgs = array();//msgtype = dl, info, warn, note, msg $csspageaddons = '';//if have css view append here $jspageaddons = '';//if have js view append here $metaaddons = '';//sometimes there need additional meta data such in case of facebook addon's $sitetitle = '';//alter if need other default view. //config defaults start //examples of how use message box system (css not included). //$msgboxmsgs[] = array('msgtype' => 'dl', 'themsg' => 'this blank message box...'); /**********************************************************your coding logic here, start*/ if ($this->session->userdata('xtr') == 'yes') { $bodycontent = $this->config->item('defaulttemplate') .'/cpanel/dashboard';//which view file $bodytype = 'full';//type of template } else { redirect('login'); } /***********************************************************your coding logic here, end*/ //double checks if default variables have been changed, start. //if msgboxmsgs array has in it, if displays in view, else nothing. if(count($msgboxmsgs) !== 0) { $msgboxes = $this->msgboxes->buildmsgboxesoutput(array('display' => 'show', 'msgs' =>$msgboxmsgs)); } else { $msgboxes = array('display' => 'none'); } if($sitetitle == '') { $sitetitle = $this->metatags->sitetitle(); //reads } //double checks if default variables have been changed, end. $this->data['msgboxes'] = $msgboxes; $this->data['csspageaddons'] = $csspageaddons;//if there additional css add above variable send view. $this->data['jspageaddons'] = $jspageaddons;//if there addictional js add above variable send view. $this->data['sitetitle'] = $sitetitle;//defaults can changed via models/metatags.php $this->data['bodytype'] = $bodytype; $this->data['bodycontent'] = $bodycontent; $this->load->view($this->config->item('defaulttemplate') .'/cpanel/index', $this->data); } } /* end of file dashboard.php */ /* location: ./application/controllers/dashboard.php */
you doing silly error
you redirecting not exitting since execution of page continue after redirecting .
by putting die() or exit ;
1st option // should in if else
redirect('login'); // or try ("location : login.php"); 2nd option or try redirecting
header('location: http://login.php'); // specify url wanna redirect die(); // or can have exit();
Comments
Post a Comment