the problem query not retrieving correct value database rather not retrieving value. whenever try print variable holds result, blank. attaching part of code
this code in model
$db = new pdo('mysql:host=localhost;dbname=login;charset=utf8', 'root', 'learningit'); $db->setattribute(pdo::attr_errmode, pdo::errmode_exception); $stmt = $db->prepare("select id members userid='$username' , password='$password'"); $stmt->execute(); $var=$stmt->fetch(pdo::fetch_assoc); foreach ((array)$var $row) { print_r($row); return $row;
& controller part
public function check() { $this->load->model('test_model'); $result=$this->test_model->data_check(); if($result[0]==1) { $this->call(); } else if($result[0]==2) { $this->call1(); } else if($result[0]==3) { $this->call2(); } else { echo "invalid id/password"; } }
you might missing $username , $password declaration in model
$username = $this->input->post('username'); // change depends in input $password = $this->input->post('password'); // change depends in input
Comments
Post a Comment