Welcome Guest, Not a member yet? Register   Sign In
messed login script
#1

[eluser]napz[/eluser]
Hi, I want to ask about log-in, I have this function named login it gets value from admin view it works fine. However if I type this to url:
http://localhost/cipms/admin/login It automatically goes to “redirect(‘adminhome/’);” function where It should go to “admin/”.

This should work because it has if($query->num_rows() > 0 ) that checks if the username and password exists in the database.

What seems to be the problem?

Can you help me with this one?


/*******************************
for log-in of admin
*******************************/
class Admin extends Controller {

public function admin(){
parent::Controller();
}

function index(){
$this->load->view(‘admin’);
$this->session->sess_destroy();
}

function login(){
$data[‘username’] = $this->input->post(‘username’);
$data[‘password’] = $this->input->post(‘password’);
$sql = “SELECT * from adminmod WHERE userName =? AND passWord=?”;
$query = $this->db->query($sql, array($data[‘username’],$data[‘password’]));


if($query->num_rows() > 0 ){
$row = $query->row();
$thisid = $row->adminmod;
$type = “Admin”;
//for session
$data = array (
‘userid’ => $thisid,
‘type’ => $type,
‘logged_in’ => TRUE,
);
$this->session->set_userdata($data);

$datamod[‘thisid’]=$thisid;
$datamod[‘type’]=$type;

$this->cimod->insert_log($datamod);
redirect(‘adminhome/’);
}else{
$this->session->set_flashdata(‘item’, ‘invalid username/password’);
redirect(‘admin/’);
}
}


}


Messages In This Thread
messed login script - by El Forum - 02-28-2010, 10:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB