prepare("INSERT INTO tokens VALUES(?, ?, ?, ?)"); $stmt->bind_param("siis", $token, $id, $expire, $data); $stmt->execute(); $query = $stmt->get_result(); return $token; } public static function validate_token($token, $user, $data) { global $mysqli; $time = time(); $stmt = $mysqli->prepare("SELECT count(*) as count, data FROM tokens WHERE token = ? AND user = ? AND expire>=? AND data LIKE ?"); $stmt->bind_param("siis", $token, $id, $time, $data); $stmt->execute(); $query = $stmt->get_result(); return $query->fetch_assoc()['count']; } public static function delete($token) { global $mysqli; $time = time(); $stmt = $mysqli->prepare("DELETE FROM tokens WHERE token = ? OR expirebind_param("sd", $token,$time); $stmt->execute(); $query = $stmt->get_result(); } }