Hello i want to know why this kind of example question never been asked before. i got this code from my college that they say this kind of code is able to prevent sql injection
we use codeigniter to build a website and here is the code to prevent sql injection
Controller
$usr = $this->input->post('userid');
$pwd = $this->input->post('passwd');
if($usr && $pwd) {
$ack = $this->mAuth->get_user($usr);
$pwx = $ack['passwd'];
if($ack && $pwd == $pwx) {
//redirect code
}
model
public function get_user($user_id='', $status=1) {
$user_id = $this->db->escape(trim($user_id));
$status = $status ? 'and user_status_uid = 1' : '';
$sql = "select * from users where user_id = lower($user_id)"
return rst2Array($sql, 'row');
}
i tried to login with 1' or 1 = 1 and etc i found and it did prevent sql injection even though it's only a plain text and password.
is there any vulnerability to this code? thanks