jeudi 7 mai 2015

If some condition - redirect to a page

I have a survey and it has 3 parts (column 'time' it has value -1, 2 or 3). Before each part users must see a page with instructions. When they see it, they should be redirected to next part of this survey. In the beginning, I show first instrustions, but I cannot make redirect for next parts. When

if ($survey_id == 4 && $row->time == 2 ) 

that means that survey is 4 and part is 2, to redirect to page with instructions. How to make if he is seen them, to redirect again to survey. I tried with session, it doesn't work Here's my code:

  <?php
        echo validation_errors();
    $survey_id = $this->uri->segment(3);
    foreach ($question as $row)
        {
    //questions and answers
    if ($survey_id == 4 && $row->time == 2 ) {
        redirect('admin/instructions_during');

        $this->load->library('session');                 
            
        $newdata = array('time' => 2);
        $this->session->set_userdata($newdata);
                
                        
    }

    if ($this->session->userdata('time') !== FALSE) {
                redirect('index/survey_show/' . $survey_id);
                                
    } 

Aucun commentaire:

Enregistrer un commentaire