Welcome Guest, Not a member yet? Register   Sign In
Problem getting results
#1

[eluser]old_guy[/eluser]
Hello,
I'm a ci newbie and fairly new to PHP/MySql as well. I'm playing around with a simple login structure using controller to call model and then view. I developed the logic first in PHP and now trying to get the same results using CI.

My problem is that my query does not return any rows. It does using non-CI php/mysql. I'm using the profiler function and it shows that my post data is correct and so is my query string. As far as I can tell the CI code is correct but I can't figure out why I'm not getting any data returned from the dB.

Below is my model code:

<?
class Login extends Model {

function login()
{
parent::Model();
}
function ck_name()
{
$username = $this->input->post('username');
$password = $this->input->post('password');

$this->load->database();
$query = $this->db->get_where('auth_users',array('username' => $username, 'password' => $password)) ;

if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$un = $row->username;
$pw = $row->password;

if ($un == $username and $pw == $password)
{
return 'yes';
}
}
}else{
return 'Username and/or Password not recognized - Please try again.';
}
}
}

?>

Currently the only result I can get passed back to my controller page is the login error message.

Would appreciate any insight into this anyone might have. Thanks!


Messages In This Thread
Problem getting results - by El Forum - 06-12-2008, 07:35 AM
Problem getting results - by El Forum - 06-12-2008, 07:41 AM
Problem getting results - by El Forum - 06-12-2008, 08:00 AM
Problem getting results - by El Forum - 06-19-2008, 01:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB