PDO::ERRMODE_EXCEPTION )); } catch (Exception $e) { die("Error : ".$e->getMessage()); } if (isset($_SESSION['username'])) { $req = $db->prepare('SELECT id FROM `authors` WHERE username=:username'); $req->execute(array( "username"=>$_SESSION['username'] )); if ($data = $req->fetch()) { $user_id = $data['id']; } } else { $_SESSION['error_msg'] = "You must be logged in to receive an send message."; header('Location: /auth/login'); } if (isset($_GET['author'])) { $req = $db->prepare('SELECT * FROM `messages` WHERE message_by=:user_id AND message_to=:author_id OR message_by=:author_id AND message_to=:user_id ORDER BY message_datetime ASC'); $req->execute(array( "author_id"=>$user_id, "user_id"=>$_GET['author'] )); $result = $req->fetchAll(); } $req = $db->prepare('SELECT username FROM `authors` WHERE id=:id'); $req->execute(array( "id"=>$_GET['author'] )); if ($data = $req->fetch()) { $destinator = $data['username']; } ?> Explore | Chiro - Canto

Discussion