[eluser]Deathmanlp[/eluser]
start.php
Code:
<?php
class Start extends Controller
{
function Start ()
{
parent::Controller ();
$this->load->library('session');
$this->load->helper('form');
$this->load->helper('url');
$this->load->library('form_validation');
$this->load->model("sites_model");
}
function _check_login()
{
$username=$this->input->post("username");
$password=$this->input->post("password");
if ($username=="ge0rgi" and $password=="123456" )
{
$this->session->set_userdata("status", "logged_in");
$this->load->view("add_site_view");
}
else
{
echo "Username and/or password wrong!";
$this->load->view("login");
}
}
function index ()
{
if (isset ($this->session->userdata) and $this->session->userdata("status")=="logged_in" )
{
$this->load->view('add_site_view');
}
else
{
$this->load->view("login");
}
}
function validate_login_form ()
{
$this->form_validation->set_rules ("username","Username","required");
$this->form_validation->set_rules ("password","Password","required");
if ($this->form_validation->run()==TRUE)
{
$this->_check_login ();
}
else
{
$this->load->view("login");
}
}
function validate_add_site_form ()
{
$url_regex='|[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i';
$url=$this->input->post("url");
$this->form_validation->set_rules("name", "Site name", "required|alpha_dash|max_length[100]");
$this->form_validation->set_rules("url", "Site URL", "required|prep_url|max_length[100]");
if ($this->form_validation->run() and preg_match ($url_regex,$url )==TRUE)
{
$this->sites_model->_add_site();
$data= array ();
$data["changes"]=$this->db->affected_rows();
$this->load->view("add_success", $data);
}
else
{
echo $this->load->view("add_site_view");
}
}
}
?>
login.php
Code:
<?php echo validation_errors () ; ?>
<?php echo form_open('start/validate_login_form'); ?>
<h1>Please Log in <br/></h1>
Username:
<?php echo form_input("username", set_value("username")); ?>
<br/> Password:
<?php echo form_password("password"); ?>
<br/>
<?php echo form_submit("value","Log in"); ?>
<?php echo form_close (); ?>
site_model.php
Code:
<?php
Class Sites_model extends Model
{
function _add_site ()
{
$data=array ();
$data["name"]=$this->input->post("name");
$data["url"]=$this->input->post("url");
$this->db->insert("sites",$data);
}
}
?> // line 12
The error
Quote:Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at J:\xampp\htdocs\ci\application\models\sites_model.php:12)
Filename: libraries/Session.php
Line Number: 662
This happens after a successful login. I get this error and my add_site_view under it.
I checked all files for empty spaces before <?php and after ?> All files are encoded UTF-8 UNIX without BOM.
I had a lot of errors like this and I fixed them, but I can't get rid of this one.