[eluser]pisio[/eluser]
hi all. I have a problem.Can you help me ?
Code:
<?php
class user extends Controller {
function user()
{
parent::Controller();
header('Content-Type: text/html; charset=utf-8');
$this->load->database(); //Активиране на базата данни.
$msg['null'] = 'is null to debug'; // Ако няма стойност на $MSG то тази прекратява проблемите.
}//main function user
function register()
{
$msg['null'] = 'is null to debug'; // Ако няма стойност на $MSG то тази прекратява проблемите.
$reg['name'] = $this->input->post('name');
$reg['pass1'] = $this->input->post('pass1');
$reg['pass2'] = $this->input->post('pass2');
$reg['mail'] = $this->input->post('mail');
if($this->uri->segment(3) == 'go')
{
$this->form_validation->set_rules('name', 'Username', 'trim|required|min_length[5]|max_length[12]');
$this->form_validation->set_rules('pass1','Password', 'trim|required|matches[pass2]|md5');
$this->form_validation->set_rules('pass2','PassworD', 'trim|required');
$this->form_validation->set_rules('mail', 'Mail', 'required');
if ($this->form_validation->run() == FALSE)
{
$msg['error'] = 1;
}
else
{
//Проверка дали съществува името.
$query = $this->db->get_where('users', array('name' => $reg['name']), 1);
if($query->num_rows == 0){
$data = array(
'name' => $reg['name'],
'pass' => md5($reg['pass1']),
'mail' => $reg['mail'],
'avatar' => '',
'signature' => '',
'notepad' => '',
'ip_reg' => $this->input->ip_address(),
'date_rag' => time()
);
echo $this->db->insert('users', $data);
$msg['error'] = 0;
}
else
{
$msg['error'] = 2;
}
}//else
}
else
{
$msg['error'] = 1;
}
$this->load->view('user/register',$msg);
}//function register
function login()
{
$this->form_validation->set_rules('name', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean');
$this->form_validation->set_rules('pass1', 'Password', 'trim|required|md5');
if ($this->form_validation->run() == FALSE)
{
$msg['error'] = 1;
}
else
{
echo "minata proverka <br/>";
$log['name'] = $this->input->post('name');
$log['pass'] = $this->input->post('pass1');
$q = $this->db->get_where('users',array('name'=> $log['name'],'pass'=>$log['pass']));
if($q->num_rows == 1)
{
$row = $q->row();
$newdata = array(
'time' => time(),
'ip' => $this->input->ip_address(),
'name' => $row->name
);
$this->session->set_userdata($newdata);
$msg['error'] = 0;
}
else
{
$msg['error'] = 2;
}
}
$this->load->view('user/login',$msg);
}// function login
}
autoload.php ->
Code:
$autoload['libraries'] = array('database','session','form_validation');
/*
| -------------------------------------------------------------------
| Auto-load Helper Files
| -------------------------------------------------------------------
| Prototype:
|
| $autoload['helper'] = array('url', 'file');
*/
$autoload['helper'] = array('form','html','url','email');
And Error is :
Quote:A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\konkurs_1\system\application\controllers\user.php:76)
Filename: libraries/Session.php
Line Number: 662