Welcome Guest, Not a member yet? Register   Sign In
Message before redirect
#1

Hi how  can i redirect after show success message ?

In my controller i have a registration method :


Code:
   function register(){
     
      $this->load->model('user_model');

     
      $table =$this->config->item('users_table');
     
      $this->load->library('form_validation');
      $this->form_validation->set_rules('email','Email',"required|is_unique[$table.email]|valid_email", array('required' => 'Inserisci la mail','valid_email'=>'la mail deve essere valida','is_unique'=>'email già presente'));
      $this->form_validation->set_rules('password','Password','required|min_length[6]');    
      $this->form_validation->set_rules('repeat_password','Repeat password','required|matches[password]');    
      $this->form_validation->set_rules('username','Username',
      "min_length[6]|max_length[12]|is_unique[$table.username]",array('min_length'=>'Lunghezza minima 6 caratteri', 'max_length'=>'Lunghezza massima 12 caratteri','is_unique'=>'Username già presente'));
       
       
       $data=[];
       
       if($this->form_validation->run()){
           
         
         
          $res=$this->user_model
          ->registerNewUser(
              $this->input->post('email'),
              $this->input->post('username'),
              $this->input->post('password'),
              $this->input->post('repeat_password')
          );
         
          $data['res']=$res;
         
          if($res!=FALSE){
       
             //set success message
             
             //set redirect after 3 seconds
             
             

           }
         
       
       }
       
       $data['errors']    = $this->user_model->errors;
       
       $data['messages']  = $this->user_model->messages;
       
       $this->load->view('user/register', $data);
   }
   


How can i do  :

//set success message
              
//set redirect after 3 seconds
Reply
#2

(06-24-2017, 05:44 AM)pippuccio76 Wrote: Hi how  can i redirect after show success message ?

In my controller i have a registration method :


Code:
   function register(){
     
      $this->load->model('user_model');

     
      $table =$this->config->item('users_table');
     
      $this->load->library('form_validation');
      $this->form_validation->set_rules('email','Email',"required|is_unique[$table.email]|valid_email", array('required' => 'Inserisci la mail','valid_email'=>'la mail deve essere valida','is_unique'=>'email già presente'));
      $this->form_validation->set_rules('password','Password','required|min_length[6]');    
      $this->form_validation->set_rules('repeat_password','Repeat password','required|matches[password]');    
      $this->form_validation->set_rules('username','Username',
      "min_length[6]|max_length[12]|is_unique[$table.username]",array('min_length'=>'Lunghezza minima 6 caratteri', 'max_length'=>'Lunghezza massima 12 caratteri','is_unique'=>'Username già presente'));
       
       
       $data=[];
       
       if($this->form_validation->run()){
           
         
         
          $res=$this->user_model
          ->registerNewUser(
              $this->input->post('email'),
              $this->input->post('username'),
              $this->input->post('password'),
              $this->input->post('repeat_password')
          );
         
          $data['res']=$res;
         
          if($res!=FALSE){
       
             //set success message
             
             //set redirect after 3 seconds
             
             

           }
         
       
       }
       
       $data['errors']    = $this->user_model->errors;
       
       $data['messages']  = $this->user_model->messages;
       
       $this->load->view('user/register', $data);
   }
   


How can i do  :

//set success message
              
//set redirect after 3 seconds

Code:
<script>
setTimeout(function () {
   window.location.href = "the url";
}, 10000); //10 sec
</script>

Offtopic:
you should send an email to the user.
https://en.wikipedia.org/wiki/Closed-loo...entication
Reply
#3

(This post was last modified: 06-24-2017, 07:35 AM by pippuccio76.)

(06-24-2017, 07:23 AM)Paradinight Wrote:
(06-24-2017, 05:44 AM)pippuccio76 Wrote: Hi how  can i redirect after show success message ?

In my controller i have a registration method :


Code:
   function register(){
     
      $this->load->model('user_model');

     
      $table =$this->config->item('users_table');
     
      $this->load->library('form_validation');
      $this->form_validation->set_rules('email','Email',"required|is_unique[$table.email]|valid_email", array('required' => 'Inserisci la mail','valid_email'=>'la mail deve essere valida','is_unique'=>'email già presente'));
      $this->form_validation->set_rules('password','Password','required|min_length[6]');    
      $this->form_validation->set_rules('repeat_password','Repeat password','required|matches[password]');    
      $this->form_validation->set_rules('username','Username',
      "min_length[6]|max_length[12]|is_unique[$table.username]",array('min_length'=>'Lunghezza minima 6 caratteri', 'max_length'=>'Lunghezza massima 12 caratteri','is_unique'=>'Username già presente'));
       
       
       $data=[];
       
       if($this->form_validation->run()){
           
         
         
          $res=$this->user_model
          ->registerNewUser(
              $this->input->post('email'),
              $this->input->post('username'),
              $this->input->post('password'),
              $this->input->post('repeat_password')
          );
         
          $data['res']=$res;
         
          if($res!=FALSE){
       
             //set success message
             
             //set redirect after 3 seconds
             
             

           }
         
       
       }
       
       $data['errors']    = $this->user_model->errors;
       
       $data['messages']  = $this->user_model->messages;
       
       $this->load->view('user/register', $data);
   }
   


How can i do  :

//set success message
              
//set redirect after 3 seconds

Code:
<script>
setTimeout(function () {
  window.location.href = "the url";
}, 10000); //10 sec
</script>

Offtopic:
you should send an email to the user.
https://en.wikipedia.org/wiki/Closed-loo...entication

I send an email in the model , but  must i insert this code on view if errors message are empty ?


Can i set an helper to redirect and use in view ? (f.e . retarded_redirect($link,$time) )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB