Welcome Guest, Not a member yet? Register   Sign In
Session flashdata
#1

[eluser]Unknown[/eluser]
I have method to check if the email is already use for registration. If it is used, it sends message via session flashdata. When I tried to create new user with same email, nothing is being showed, but if I refresh page, message is showed properly. What seams to be the problem.

Code for creating message:

Code:
function create() {
      $this->load->library('form_validation');
      $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
      $this->form_validation->set_rules('ime', 'trim|required');
      $this->form_validation->set_rules('prezime', 'trim|required');
      $this->form_validation->set_rules('pass', 'trim|required|min_lenght[4]|max_lenght[32]');
      $this->form_validation->set_rules('pass2', 'trim|required|matches[password]');        
      
      if($this->form_validation->run() == FALSE){$this->index(); }
      else {if( $this->admin_model->create_user() == FALSE)
             {
                $this->session->set_flashdata('message', 'Ovaj email je upotrebljen za kreiranje admina');
                $message =  $this->session->flashdata('message');
                $data['message']= $message;
                $data['main_content'] = 'admin_login';
                 $data['title'] = 'Administrator Login';
                $this->load->view('admin/template', $data);
             }
             else
                 {  
                       $this->index();
             }
            
             }
        
    }//end of create

And this is the code for generate message:

Code:
<?php if(isset($message)) : ?>
<div id="error_text">&lt;?php echo $message ?&gt;</div>
&lt;?php endif; ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB