Welcome Guest, Not a member yet? Register   Sign In
Trouble Accessing DB with HMVC Modular Extensions
#1

[eluser]USCTrojans[/eluser]
Hello, I am trying to send variables to a sql database to validate and then would like to return a variable to my controller. Here is my code, I've looked around for hours online and can not seem to get this working? I have tested everything possible, I know my variables work in other functions (the login array) and I know that my code igniter setup works with my database. I used this with another setup. I'm only a few days into code igniter so any help/advice on this would be greatly appreciated

Code:
<?php

class Db_validate_login extends MX_Model {

function __construct()
     {
         parent::__construct();
     }

function db_validate_login($login)
  {
   $this->db->where('email_address', $email_address);
   $this->db->where('password', $password);
   $query = $this->db->get('membership_information');
  
   if($query->num_rows == 1)
   {
    return true;
   }
  }
}

controller function being utilized. For some reason I just get a blank page where this function should redirect either to welcome or homepage. Thanks again
Code:
function database_Login($login)
{
  $this->load->model('db_validate_login', $login);
  $query = $this->Db_validate_login->db_validate_login();
  if ($query)
   {
    redirect('welcome');
    echo $login['email_address'];
   }
  else
   {
   redirect('homepage');
   }
}
#2

[eluser]Amitabh Roy[/eluser]
Code:
function db_validate_login($email_address, $password)
  {
   $this->db->where('email_address', $email_address);
   $this->db->where('password', $password);
   $query = $this->db->get('membership_information');
  
   if($query->num_rows == 1)
   {
       return true;
   }else{
    return false;
   }
  
  }
}




//am not sure what the $login parameter was
function database_Login($email_address, $password)//replaced $login
{
  $this->load->model('db_validate_login');
  $query = $this->Db_validate_login->db_validate_login($email_address, $password);
  if ($query)
   {
    redirect('welcome');
   // echo $login['email_address'];
   }
  else
   {
   redirect('homepage');
   }
}




Theme © iAndrew 2016 - Forum software by © MyBB