[eluser]Johonunu[/eluser]
Here is my code :
Code:
<?php
class Login extends Controller
{
function __construct()
{
parent::Controller();
$this->output->enable_profiler(TRUE);
}
function index()
{
$podaci['naslov'] = "Admin System - Login";
$this->load->view('admin/login_view',$podaci);
}
function provera()
{
if($this->input->post('login'))
{
$this->load->library('form_validation');
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->form_validation->set_rules('username','Username','required');
$this->form_validation->set_rules('password','Password','required');
if($this->form_validation->run() == FALSE)
{
$podaci['naslov'] = "Admin System - Login";
$this->load->view('admin/login_view',$podaci);
}
else
{
$query = $this->db->get_where('users',array('ime'=>$username,'lozinka'=>$password));
if($query->num_rows() > 0)
{
echo "Loged in !";
}
else
{
$this->session->set_flashdata('error','Wrong username or password !');
$podaci['naslov'] = "Admin System - Login";
$this->load->view('admin/login_view',$podaci);
}
}
}
}
}
?>
And my problem :
At the end of the code, when I login with wrong data, the flash data is supposed to send me an error message, but the flashdata isn't send. But when I reload the message is showen ! Strange, like it is one step behind ? Can anybody explan in some steps how to use flashdata, or is there a way to send a custom message with form_validation ?
Thanks, Johonunu :lol:
P.S. I read the user guide !