Welcome Guest, Not a member yet? Register   Sign In
Best method for sending form variables to a model ?
#4

[eluser]ywftdg[/eluser]
I have been trying to get this to work in a MVC setup, but nothing works. It works when its just in controller as:

Code:
$data['password'] = $this->input->post('password');
            $data['email'] = $this->input->post('email');
            
            $this->db->select('*');
            $this->db->where('designer.dEmail' , $data['email']);
            $this->db->where('designer.dPassword' , $data['password']);
            $this->db->from('designer');
            $query = $this->db->get();

But if I try and put this in a model/controller setup, the variables wont pass. Any suggestions on how you would flip the query on this to a model and pass the variables email and password? Then bring back to the controller for a if statement?

MY attempted MVC is:

model
Code:
function check_emailpassword($data)        {    
        $email = $data['email'];
        $password = $data['password'];
            
           $this->db->select('*');
        $this->db->where('designer.dEmail' , $email);
        $this->db->where('designer.dPassword' , $password);
        $this->db->from('designer');
        $query = $this->db->get();
        return $query->result();
       }

controller
Code:
function login()
    {

        $this->load->library('validation');
        $this->load->model('Designers_model', 'designer');
        
    
        if ($this->validation->run() == TRUE)    {
            $data['password'] = $this->input->post('password');
            $data['email'] = $this->input->post('email');
            
            $this->load->model('Designers_model', 'designer');
            $query = $this->designer->check_emailpassword($data);
            
            if ($query->num_rows() > 0) { // DB TRUE
                  redirect('designers/account');
            } else    { // QUERY FALSE
                $this->load->view('login_view');
                }
        }
        
        else    { // Validation FALSE
            $this->load->view('login_view');
        }

    }


Messages In This Thread
Best method for sending form variables to a model ? - by El Forum - 07-22-2007, 03:44 PM
Best method for sending form variables to a model ? - by El Forum - 07-22-2007, 04:41 PM
Best method for sending form variables to a model ? - by El Forum - 07-23-2007, 11:14 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 12:42 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 02:26 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 02:38 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 02:49 AM
Best method for sending form variables to a model ? - by El Forum - 07-29-2008, 10:35 AM
Best method for sending form variables to a model ? - by El Forum - 11-25-2008, 12:05 PM
Best method for sending form variables to a model ? - by El Forum - 11-25-2008, 12:38 PM
Best method for sending form variables to a model ? - by El Forum - 11-25-2008, 12:50 PM
Best method for sending form variables to a model ? - by El Forum - 11-26-2008, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB