[eluser]theif_of_always[/eluser]
Problem: When I input a username or password. Nothing really happens. Or at least I don't think so. I keep getting same non-response or maybe I am just misdirecting it? My code is below. I am not worried about hashing it at the moment, just want to get this to work properly first. Thanks in advance!
MY CONTROLLER:
Code:
public function login() {
if (isset( $_POST['username'] ) && isset( $_POST['password'] ))
{
$this->form_validation->set_rules("password", "password", "trim|required");
$this->form_validation->set_rules("username", "username", "trim|required");
if($this->form_validation->run() == FALSE)
{
$this->load->model("LoginModel");
$isAuth = $this->LoginModel->login($_POST);
if($isAuth == TRUE)
{
$this->session->set_userdata('user', $_POST['username']);
redirect("dashboard/login");
echo 'true';
}
else {
$this->load->view("login_view");
echo 'yeah';
}
}
}
else
{
$this->load->view("login_view");
}
}
}
MY MODEL
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class LoginModel extends CI_Model {
public function login($_POST)
{
$this->db->where("username", $_POST['username']);
$this->db->where("password", $_POST['password']);
$count = $this->db->count_all_results("users");
if ($count == 1) {
$isAuth = TRUE;
} else {
$isAuth = FALSE;
}
return $isAuth;
}
}
MY VIEW
Code:
<?php
$this->load->view("header_view");
?>
<?php echo validation_errors();?>
<?php echo form_open('dashboard/login');?>
<label for="username">Username: </label><br />
<input name='username' id="username" type='text' value='<?php echo set_value('username'); ?>' /><br />
<label for="password">Password: </label><br />
<input name='password' id="password" type='text' value='<?php echo set_value('password'); ?>' /><br />
<input type='submit' id="submit" value="Submit" />
</form>
<?php
$this->load->view("footer_view");
?>