11-02-2009, 05:37 PM
[eluser]GamingFusion[/eluser]
I have made a simple Login Script that asks the user for their username and password.
Heres my problem, when i go to the login page it doesn't display. I think it has somehting to do with my if statement at the top but it should work.
here is my code
----View----
----model----
I have made a simple Login Script that asks the user for their username and password.
Heres my problem, when i go to the login page it doesn't display. I think it has somehting to do with my if statement at the top but it should work.
here is my code
----View----
Code:
<?php
$this->database->checkLogin();
if ($loggedIn == FALSE)
{
?>
<!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><?=$title?></title>
</head>
<body>
<h1><?=$heading?></h1>
<hr />
<?php echo validation_errors(); ?>
<?=form_open('theater/checkLogin');?>
<table>
<tr>
<td>Username: </td><td><input name="username" class="input" type="text" value="<?php echo set_value('username'); ?>" /></td>
</tr>
<tr>
<td>Password: </td><td><input name="password" class="input" type="password" />
</td>
<td><?=form_submit('submit', 'Login');?></td>
</tr>
</table>
</form>
</body>
</html>
<?php
}else{
echo 'Logged In';
//redirect('theater', 'refresh');
}
?>
----model----
Code:
function checkLogin()
{
$u1 = get_cookie('username');
$p1 = get_cookie('password');
$logged = $this->db->get_where('users', array ('username' => $u1, 'password' => $p1));
//Rename some of the $logged['variables'] with easier names.
$uId = $logged['id'];
$uName = $logged['username'];
if ($uName) {
return $data['loggedIn'] = TRUE;
}else{
return $data['loggedIn'] = FALSE;
}
}