[eluser]Unknown[/eluser]
Hi, I am new to codeignetor and trying to create a login form when i am trying to connect to the database the above error is displaying please anybody see the below script and please guide me to what should i change.
login.php //controller
<?php
class Login extends CI_Controller{
function __construct()
{
parent::__construct();
$this->today = date("d/m/Y");
}
function index()
{
$data['main_content'] = 'login_view';
$data['today'] = $this->today;
$this->load->view('includes/template', $data);
}
function login_process()
{
$this->load->model('login_model');
$data = array($this->input->post('user_name'), $this->input->post('pass'));
$this->login_model->check_login($this->input->post('user_name'), $this->input->post('pass'));
}
}
?>
login_view.php //view
<div>
<?php $this->load->helper('Form'); ?>
<?php echo form_open('login/login_process'); ?>
<table align="center">
<tr>
<td colspan="3" align="center"></td>
</tr>
<tr>
<td><b>User Name</u></td>
<td>:</td>
<td><input type="text" name="user_name"></td>
</tr>
<tr>
<td><b>Password</b></td>
<td>:</td>
<td><input type="password" name="pass"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="submit" name="submit"></td>
</tr>
</table>
</form>
<div>
login_model.php //model
<?php
class Login_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
function check_login($data1, $data2)
{
$sql = "SELECT * FROM admin WHERE Username = ? AND Pass = ?";
$num = $this->db->query($sql, array($data1, $data2));
if($num!= 0)
{
redirect('home_view', 'refresh');
}else{
$this->load->view('login_view');
}
}
}
?>