I want to fetch the userid from my php code for this I create a class for fetch record this is my code
My database Manager Class
public function executeQuery($query) {
$result = mysql_query($query);
if ($result === false) {
$this->closeConnection($this->conn);
exit;
}
// extract data from results, returning an associative array
$rows = Array();
while ($row = mysql_fetch_assoc($result)) {
$rows[] = $row;
}
return $rows;
}
Class for Fetch records
function checkLogin($arr)
{
require_once(FRONT_ROOT_PATH.'DatabaseManager.php');
$query ="Select * from tbusers where username='".$arr['username']."'and
password='".$arr['password']."'";
$db= new DatabaseManager();
$result=$db->executeQuery($query);
return $result;
}
and this function i am calling here
if(isset($_POST['addlogin']))
{
$obj= new LoginManager();
$userlist=$obj->checkLogin($_POST);
if(Count($userlist)>0)
{
header('location:/ProjectDream/view/home/home.php');
}
else
{
echo "Login Failed";
}
Now from here I want to add userid in session Please tell me how can i do it?