-2
try{
$query = "SELECT user_id FROM user WHERE username = '".$username."'";
$result = $dbhandle->query($query,PDO::FETCH_OBJ);
//$stmt->bindParam(":username",$username);
// $result = $stmt->fetchAll(PDO::FETCH_BOTH);
while($row = $result->fetch()){
$id = $row['user_id'];
$_SESSION['user_id'] = $id;
}
}catch(PDOException $e){ echo $e->getMessage();}
你會得到什麼錯誤? – TechWisdom