glenelkins Posted June 1, 2009 Share Posted June 1, 2009 Hi I get the usual header info error which can be cleared with ob_start() but id rather not! Its saying: Warning: Cannot modify header information - headers already sent by (output started at /home/clients/public_html/cms/application/Classes/registry.class.php:33) in /home/clients/public_html/cms/application/Controller/admin.php on line 49 Here is the registry class: ( where in here is any output being produced? There isnt! ): <?php /* Class; Registry * Defenition: Used to avoid using GLOBAL variables */ class Registry { // Array to hold variables private $vars = array(); /* function: __set ( $index, $value ) * creates a variable inside the $vars array */ function __set ( $index, $value ) { $this->vars[$index] = $value; } /* function: __get ($index) { * returns the value of a variable in our array */ function __get ( $index ) { return ( $this->vars[$index] ); } } ?> Here is the admin.php file: <?php /****************************************/ /* The default administrator controller */ /****************************************/ class Admin extends Controller { function index() { // The index function should just show the login view // Lets setup some template variables $this->view->assign ( 'site_title', $this->registry->shared->get_site_detail ( 'title' ) ); $this->view->assign ( 'section_title', 'Administrator Area' ); $this->view->assign ( 'page_title', 'Login' ); // Load up the view $this->view->display ( 'admin/login' ); } function login() { // Get a copy of the session object $session = $this->registry->session; // Here we control the actual full login routine // Get user and pass $username = $_POST['username']; $password = $_POST['password']; // Make sure username exists $result = $this->db->fquery ( "SELECT * FROM `admin_users` WHERE `username` = '$username'" ); if ( $result->fnum_rows() ){ // username exists check password is correct $result = $result->farray(); if ( $result['password'] == md5 ( $password ) ) { //ok // log the user in $_SESSION[$session->key]['admin']['logged'] = 'yes'; $_SESSION[$session->key]['admin']['username'] = $username; // Reset section and page to site default header ( "Location: {$this->config['base_url']}" ); } else { die ( "Password invalid" ); } } else { die ("Username invalid" ); } } } ?> Quote Link to comment Share on other sites More sharing options...
gevans Posted June 1, 2009 Share Posted June 1, 2009 What code is calling these classes? On line 49 you trying to use a header to change the current url, if you're already outputted anything from your code this will fail (as you've seen) http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment Share on other sites More sharing options...
glenelkins Posted June 1, 2009 Author Share Posted June 1, 2009 nothing else has been displayed. its the controller that is repsonsible for displaying output. as you can see in the login() function nothing is outputted before the header function. basically this is an MVC framework im putting together with a modified version of the smarty engine as part of it. not only is it a framework but also a cms ( which is hugely reliant on smarty ) so as the usual mvc structure nothing is outputted until the controller says! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 1, 2009 Share Posted June 1, 2009 Read the error - output started at ..../registry.class.php:33 (line 33) Did you check what is in that file on line 33? The posted code has 32 lines from the opening php tag to the closing php tag. You apparently have something in the file after the closing php tag (any characters not contained within php tags is raw content and is sent to the browser.) Quote Link to comment Share on other sites More sharing options...
DarkSuperHero Posted June 1, 2009 Share Posted June 1, 2009 if its nothing but php is in the file, try leavng out the closing php tag, that way you know no white space is being read as output. Quote Link to comment Share on other sites More sharing options...
glenelkins Posted June 1, 2009 Author Share Posted June 1, 2009 ah it may be white space ill check that Quote Link to comment Share on other sites More sharing options...
glenelkins Posted June 1, 2009 Author Share Posted June 1, 2009 ha ha! that was it, there was a white space at the end, stupid thing lol! thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.