Welcome Guest, Not a member yet? Register   Sign In
Flashdata problems...
#1

[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 !
#2

[eluser]TheFuzzy0ne[/eluser]
The message in your case should be passed through in the $podaci array.

Code:
$podaci['error'] = 'Wrong username or password !';

Flashdata is used to pass data from one request to another. It's usually set just before a redirect to another page.
#3

[eluser]Johonunu[/eluser]
You're right ! Thanks for explanation !
Thanks, TheFuzzy0ne !




Theme © iAndrew 2016 - Forum software by © MyBB