[eluser]GamingFusion[/eluser]
I am creating a site that has a simple login/logout functionality.
I am getting this error after submitting the form
Quote:Fatal error: Cannot use object of type CI_DB_mysql_result as array in *Censored*/system/application/models/members.php on line 18
Heres my form
Code:
<?php
if (isset($logged_in) == true) {
if ($logged_in == TRUE)
{
redirect('/social/', 'refresh');
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SocialCrab | Login</title>
<link rel="stylesheet" type="text/css" href="<?=base_url()?>assets/css/login.css" media="screen" />
</head>
<body>
<div class="container">
<div class="header">
<img src="<?=base_url();?>assets/images/logo.png" alt="Logo" />
</div>
<div class="content">
<?php
$nowTime = '%h:%i %a';
$nowDay = '%d';
$nowMonth = '%m';
$time = time();
$errors = validation_errors();
if ($errors) {
echo '<div class="error">';
echo validation_errors();
echo '</div>';
}
?>
<center><h2>Login</h2></center>
<?=form_open('login/validate')?>
<?=form_hidden('time', mdate($nowTime, $time))?>
<?=form_hidden('day', mdate($nowDay, $time))?>
<?=form_hidden('month', mdate($nowMonth, $time))?>
<table>
<tr><td>Email: </td><td><?=form_input('email', set_value('email'))?></td></tr>
<tr><td>Password:</td><td><?=form_password('password')?></td></tr>
<tr><td><?=form_submit('submit', 'Login')?></td></tr>
</table>
</div>
<div class="footer">
Copyright 2010 SocialCrab
</div>
</div>
</body>
</html>
and heres my controller for that view file
Code:
<?php
class Login extends Controller {
function Login()
{
parent::Controller();
$this->load->helper('url');
$this->load->helper('form');
$this->load->helper('date');
}
function index()
{
$data['logged_in'] = false;
$this->load->view('socialcrab/login/index', $data);
}
function validate()
{
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
$this->form_validation->set_rules('password', 'Password', 'trim|required|sha1');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('socialcrab/login/index');
}
else
{
$this->load->model('members');
if ($this->members->login() == FALSE)
{
}
}
}
}
?>
and heres login function from my model(the "*" shows line 19)
Code:
function login()
{
$email = $this->input->post('email');
$password = $this->input->post('password');
$logged = $this->db->get_where('users', array ('email' => $email, 'password' => $password));
if ($logged) {
* $uId = $logged['id'];
$uFirst = $logged['first'];
$uLast = $logged['last'];
}else{
echo 'No User';
}
if ($uName) {
return TRUE;
}else{
return FALSE;
}
}
whats wrong?
*EDIT* I have also just noticed that i get the same error no matter what email i enter. even the correct one. is is it not checking the database properly?