Jump to content

[SOLVED] Cant Modify Header Info


glenelkins

Recommended Posts

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" );

	}

}

}

?>

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.