Im trying to make a token based system for my site, and im new in making classes in php. When i run a PDO query inside check function the page stop working.
<?php
date_default_timezone_set("Europe/Copenhagen");
include_once ("../connect.php");
class userToken {
public $token;
public $tokenid;
public $userId;
public $expire;
function __construct($t) {
$this->tokken = $t;
$this->check();
}
public function check() {
try {
$checkToken = $DBH->prepare("
SELECT *
FROM token
WHERE token = :token
LIMIT 1
");
$checkToken->execute(array(':token' => "186382asd"));
} catch(PDOException $e) {
echo $e->getMessage();
echo '[{"error":true"}]';
exit();
}
return "done";
}
}
$test = new userToken("186382asd");
echo $test->token;
?>
Aucun commentaire:
Enregistrer un commentaire