Welcome Guest, Not a member yet? Register   Sign In
Cannot modify header information
#1

[eluser]Nathan Payne[/eluser]
http://www.haunted-houses.net/admin

I am getting the following error:

Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/phpwhizn/public_html/haunted-houses.net/system/application/libraries/Layout.php:37)

Filename: libraries/Session.php

Line Number: 662

This happens when I try to access the admin section of my sites. I have attached the code for my admin section below.

Controller:
Code:
<?php
    
    class Admin extends Controller{
        
    function Admin()
    {
        parent::Controller();
        $this->load->library('session');
    }
    
    function index()
    {
        $this->load->model('admin_model', '', TRUE);
        
        $this->layout->view('login');
    }
    
    function verify()
    {
        if ($this->input->post('username'))
        {
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            
            $this->admin_model->authorize($username, $password);
        }
            $this->layout->view('login');
        
    }}

Model:
Code:
<?php

    class Admin_model extends Model{
        
        function Admin_model(){
            parent::Model();
        }
        
        function authorize($username, $password){
            $data = array();
            $this->db->select('id, username');
            $this->db->where('username', $username);
            $this->db->where('password', $password);
            $this->db->limit(1);
            
            $q = $this->db->get('users');
            if ($q->num_rows() > 0){
                $row = $q->row_array();
                $_SESSION['userid'] = $row['id'];
                $_SESSION['username'] = $row['username'];
                redirect('admin/dashboard','refresh');

            }else{
                $this->session->set_flashdata('error', 'Your login details failed!');
            }
        }
                
        }

View:
Code:
<div id="content">
    <h1>Admin Login</h1>
    &lt;?php if ($this->session->flashdata('error'))
    {
        echo $this->session->flashdata('error');
    }
    ?&gt;
    &lt;?php
    $username = array('name' => 'username', 'id' => 'username', 'size' => 20);
    $password = array('name' => 'password', 'id' => 'password', 'size' => 20);
    
    echo form_open("admin/verify");
    echo "<p><label for='username'>Username</label><br />";
    echo form_input($username) . "</p>";
    echo "<p><label for='password'>Password</label><br />";
    echo form_password($password) . "</p>";
    echo form_submit('submit', 'login');
    echo form_close();
    ?&gt;
    
    
</div></div>

<div id="sidebar">
    <div id="latesthouse">
        <h1>Latest Houses</h1>
        <h2>hb</h2>
            <p class="latesthouse"><img class="latesthouse" src="&lt;?php echo base_url().'images/picture.jpg'; ?&gt;"
        alt="House" />rdtfyvguhinjo
        
        </p>
    </div>

Also when I submit the form I get the following:
Quote:Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/phpwhizn/public_html/haunted-houses.net/system/application/libraries/Layout.php:37)

Filename: helpers/url_helper.php

Line Number: 528


Messages In This Thread
Cannot modify header information - by El Forum - 11-20-2008, 07:15 PM
Cannot modify header information - by El Forum - 11-20-2008, 07:48 PM
Cannot modify header information - by El Forum - 11-20-2008, 08:13 PM
Cannot modify header information - by El Forum - 11-21-2008, 07:09 AM
Cannot modify header information - by El Forum - 11-21-2008, 07:44 AM
Cannot modify header information - by El Forum - 11-21-2008, 02:02 PM
Cannot modify header information - by El Forum - 11-21-2008, 05:21 PM
Cannot modify header information - by El Forum - 11-21-2008, 05:56 PM
Cannot modify header information - by El Forum - 11-21-2008, 06:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB