Welcome Guest, Not a member yet? Register   Sign In
when csrf is true only works in firefox and not in other browser
#8

[eluser]Javier Fonseca[/eluser]
I get error when I try to login or signup a new user.

Code:
<?php

class Inicio extends CI_Controller {

    public function __construct()
       {
            parent::__construct();
            session_start();
            $this->load->model('feed_model');
            $this->load->model('membresia');
            $this->load->library('form_validation');
            
            
       }
    function index()
    {
        
        $data['query'] = $this->feed_model->getAllRows();
        $this->load->view('inicio_view', $data);
    }
    
    function inicio_usuario()
    {
        $data['query'] = $this->feed_model->getAllRows();
        $this->load->view('inicio/inicioUsuarios', $data);
        
    }
    
    function evento()
    {
        $data['query'] = $this->feed_model->geteventos();
        $this->load->view('inicio/eventos', $data);
    }
    
    function post() //not tested yet
    {
        $id = $this->uri->segment(3);
        $data['verificar'] = $this->feed_model->vcom($id);
        $data['post'] = $this->feed_model->getpost($id);
        $data['comentario'] = $this->feed_model->getcomentarios($id);
        
        $this->load->view('inicio/post',$data);
        
        $this->form_validation->set_rules('comentario', 'Coemntario', 'trim|required');
        
        
        
    if($this->form_validation->run() !== FALSE)
        
        {            
            $this->load->helper('date');
            
            $now = time();
            
            $this->feed_model->comentar(
                                $this->input->post('idpost'),
                                $this->session->userdata('username'),
                                $this->input->post('comentario'),
                                unix_to_human($now));
            redirect('inicio/post/'.$id);
            
        }
    
    }
    function nuevoUsuario()
    {


        
        // field name, error message, validation rules
        $this->form_validation->set_rules('nombre', 'Nombre', 'trim|required');
        $this->form_validation->set_rules('apellido', 'Apellido', 'trim|required');
        $this->form_validation->set_rules('correo', 'Correo', 'trim|required|valid_email');
        $this->form_validation->set_rules('usuario', 'Usuario', 'trim|required|min_length[6]');
        $this->form_validation->set_rules('password', 'Contraseña', 'trim|required|min_length[6]|max_length[32]');
        $this->form_validation->set_rules('password2', 'Confirmar Contraseña', 'trim|required|matches[password]');
        
        
    if($this->form_validation->run() == FALSE)
        {
            redirect('inicio/signup');
        }
        
        else
        {            
            $data = array(
                'Nombre' => $this->input->post('nombre'),
                'Apellido' => $this->input->post('apellido'),
                'Correo' => $this->input->post('correo'),            
                'Usuario' => $this->input->post('usuario'),
                'Contraseña' => md5($this->input->post('password')),
                'tipo' => 2                        
            );
                
            $q = $this->membresia->registrarse($data);
                    
            if($q == true)
            {
                redirect('inicio/bienvenida');
            }
            
            
        }
            
    }            
    
    function login()
    {
        $this->load->view('inicio/login_form');
        
    }
    
    function loginin()
    {
        
        $this->form_validation->set_rules('username','','required');
        $this->form_validation->set_rules('password','','required|min_length[6]');
        
        
        if($this->form_validation->run() !== false)
        {
            
            $res = $this
                ->membresia
                ->verificarUsuario(
                $this->input->post('username'),
                $this->input->post('password')
                );
                
            if( $res !== false)
            {
                $_SESSION['usuario'] = $this->input->post('username');
                
                $data = array(
                'username' => $this->input->post('username'),
                'is_logged_in' => true
                );
                $this->session->set_userdata($data);
                if($res->tipo == 1)
                {
                    
                    redirect('cms');
                }
                else
                {
                    redirect('inicio/inicio_usuario');
                }
                
            }
        
        }
        else
            {
                redirect('inicio/login_form');
            }
    }
    
    function olvido()
    {
        $this->form_validation->set_rules('correo', 'Correo', 'trim|required|valid_email');
        
        
        if($this->form_validation->run() !== false)
        {
            redirect('inicio');
        }
        else
        {
            $this->load->view('inicio/olvido');
        }
    }
    
    function logout()
    {
        session_destroy();
        redirect('inicio');
    }
    
    
    
}


Messages In This Thread
when csrf is true only works in firefox and not in other browser - by El Forum - 06-07-2011, 11:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB