$sql = "UPDATE users SET lastalive=NULL, username=:username WHERE uid=:uid"; $st = $this->db->prepare($sql); $st->bindParam(':username', $username); $st->bindParam(':uid', $this->uid); $st->execute(); $this->username = $username; } return $this->username; } } if (isset($_POST['action'])) { $action = $_POST['action']; $user = new user(); $chat = new chat($user); $user->updateLastAlive(); switch ($action) { case 'newmsg': $data = $_POST; $chat->newMessage($data); break; case 'update': $chat->updateUser(); break; default: break; } //var_dump($_POST); } ?>