Welcome Guest, Not a member yet? Register   Sign In
Blank page after reloading
#1

[eluser]Linkark07[/eluser]
Good afternoon.

I have been having a particular problem after doing a submit: if I try to reload the page (f5), instead of reappearing, I get a blank page.

An example: I have a dropwdown which sends the user to another page; this page depends on the choice of the user. In the next page, if the user clicks refresh or presses f5, a blank page appears.

Likewise, if the user clicks the back button for return to the dropwdown and chooses another option, instead of loading the correct page, the blank page appears.

Some of the code here:

Dropdown

Code:
div id="content">

<?php
$attributes = array('class' => 'bootstrap-frm',
    'name' => 'formulario',
    'id' => 'formulario');
?>
            <?=form_open(base_url().'site/buscarcurso', $attributes)?>
              <label>Curso</label><select class="cursos" id="cursos" name="cursos"><p>&lt;?=form_error('cursos')?&gt;</p>
              </br>
            &lt;?php

            foreach($grupos as $row)
            {
              echo '<option value="'.$row->nombre.'">'.$row->nombre.'</option>';
            }
            ?&gt;
            </select><p></p>
            
              &lt;input type="hidden" name="id" readonly/&gt;&lt;p>
              
              &lt;input type="hidden" name="token" value="&lt;?=$token?&gt;" /&gt;
              &lt;input type="submit" name="submit" value="Confirmar Datos" /&gt;
            
               &lt;?=form_close()?&gt;

Controller:
Receives the post value.
Code:
public function buscarcurso(){
     if($this->input->post('token') && $this->input->post('token') == $this->session->userdata('token'))
    {
               $this->form_validation->set_rules('cursos', 'Cursos', 'trim|xss_clean');
             //   $this->form_validation->set_message('required', 'Se requiere que elija un curso');
                if($this->form_validation->run() == FALSE)
                {
                    $this->inscribir();
                }else{
                    $nombre = $this->input->post('cursos', TRUE);
              
                 //   $this->load->view("prueba", $info);
                  
                  
             $buscanombre = $this->curso_model->obtenerdatosgrupo($nombre);
             // $this->session->set_flashdata('nombre', $nombre);
              //  redirect(base_url().'site/confirma_inscr');  
                    $this->confirma_inscr($nombre);
                        
                     return $nombre;
                }
       }
  }
The page that brings a blank page if reloaded
Code:
public function confirma_inscr($nombre){ //Esta página es para confirmar la inscripción. El parámetro viene de la función buscarcurso();
      if($this->session->userdata('is_logued_in')){

       $data['titulo'] = 'Confirmar Inscripción';
       $data['query'] = $this->curso_model->obtenerdatosgrupo($nombre);
       //Ahora trae más columnas de la tabla curso.

    $data['token'] = $this->token();
  
    $this->load->view("site_header", $data);
      $this->load->view("site_navon");
    $this->load->view('Estudiante/confirmarcurso_view', $data);  
      $this->load->view("site_footer");
      }else{
         $this->not_logged();
      }
  }

I have noted that on the browser, instead of appearing confirma_inscr when the page is loaded for the first time, the function buscarcurso appears. Is that a cause of the problem?

Thanks in advance.

Edit: This also happens when a form validation fails and then I submit with the correct values the form requires. The blank page appears.
#2

[eluser]CroNiX[/eluser]
Is this correct (logued)?
Code:
if($this->session->userdata('is_logued_in')){

And what does this method do?
Code:
$this->not_logged();

Also, in your buscarcurso() method, you do this:

Code:
$this->confirma_inscr($nombre);
return $nombre;

So it looks like it will show the view real quick (in confirma_inscr()) and then return a value to the calling function.
#3

[eluser]Linkark07[/eluser]
First: yes, it confirms if the user is logged in.

Second: it calls a page telling the user he/she is not logged in.

Third: instead of using buscarcurso(), confirma_inscr() should receive the post value?
#4

[eluser]InsiteFX[/eluser]
For one you should not need the base_url() in the form_open
#5

[eluser]Linkark07[/eluser]
Ok, I removed base_url() from form open and moved part of the code of buscarcurso to confirm_inscr. Now, the form post the data to confirm_inscr instead of buscarcurso.

But still, the same problems persists. F5, Firefox brings a confirmation window saying it must send information that will repeat any action. After pressing resend, the blank page appears.
#6

[eluser]Linkark07[/eluser]
Found the problem. It was this:

Code:
&lt;input type="hidden" name="token" value="&lt;?=$token?&gt;" /&gt;

Now the pages reload and the blank page disappeared.

Thanks for everything.




Theme © iAndrew 2016 - Forum software by © MyBB