How to prevent me from inserting myself when doing F5

0

I have the following situation. I'm doing a submit to a form, but when I refresh the page, I redo the insert of the data in the table. Searching in internet the solution that is given is that a redirect with header is made to the page, which is not feasible for me.

My question is this, there is some way that you can clean the variables without reloading the page. Then I leave the code with the validation that I have done and even then I can avoid it.

        if(input_post('enviar')){

            $this->cli->set_comentario();
            $this->u_active = '';
            $this->p_active = 'active';  
            $this->error = '<div class="alert alert-success" role="alert">El comentario ha sido enviado</div>';

        }

Set_comment function

    public function set_comentario(){

        $id = input_post('id');
        $comentario = input_post('cometario');

        $data = array('idus'=>$_SESSION["credentials"]["userId"],
                      'idtar'=>$id,      
                      'coment'=>$comentario,      
                     );
        classDb::insert_db('comentarios',$data);
    }

Thanks

    
asked by Yoel Rodriguez 28.02.2018 в 23:34
source

0 answers