Warning: Cannot modify header information - headers already sent by (output started at -------\library\headerProperties.php:43) in --------\library\template.php on line 235
I was advised to use ob_start() and ob_flush() so I looked them up in php manual so this is what I did:
headerProperties.php:
Code: Select all
class headerProperties {
public $title;
public $templateName;
public function setTemplate(){
$result = mysql_query('SELECT * FROM sys_settings') OR die(mysql_error());
$template = mysql_fetch_array($result);
$this->templateName = $template['sys_site_template'];
}
public function selectTemplate(){
$result = mysql_query('SELECT * FROM sys_settings') OR die(mysql_error());
$title = mysql_fetch_array($result);
}
public function loadTemplate(){
echo '<link rel="stylesheet" type="text/css" href="template'.'/'.$this->templateName.'/'.'css'.'/'.$this->templateName.'.css" />';
echo '<link rel="stylesheet" type="text/css" href="template/component/component.css" />';
}
public function setTitle(){
$result = mysql_query('SELECT * FROM sys_settings') OR die(mysql_error());
$title = mysql_fetch_array($result);
$this->title = $title['sys_site_title'];
}
public function insTitle(){
echo '<title>'.$this->title.'</title>';
}
public function insMeta(){
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
}
public function createHeader(){
echo '<head>';
$this->insTitle();
$this->insMeta();
$this->loadTemplate();
echo '</head>';
}
public function displayHeader(){
ob_start($this->createHeader());
ob_flush();
}
}
Code: Select all
public function logoutFunc(){
$sub_logout = $_POST[sub_logout];
if(false !== ($sub_logout == 'Logout')){
unset($_SESSION[user_ID]);
unset($_SESSION[user_name]);
header('refresh: 1;');
}else{
echo '<form action="" method="post" name="logout">
<input name="sub_logout" type="submit" value="Logout" />
</form>';
}
}
public function loggedUserFunc(){
echo 'You are logged in.';
ob_start($this->logoutFunc());
ob_flush();
}
); All I had to do was: