<?php
require_once "Login.php";
header("Content-Type: text/html; charset=UTF-8");
$dsn = "mysql:host=.....;dbname=.....";
$username = ".....";
$password = ".....";
try {
$pdo = new PDO($dsn, $username, $password);
$pdo->query("SET NAMES utf8");
$pdo->query("SET CHARACTER_SET utf8_polish_ci");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Próba logowanie i pobieranie wartości
if (Login::getLogin()) {
echo "Logout..";
Login::logout();
var_dump(Login::checkSession());
echo "<br/>";
}
$login = new Login($pdo);
echo "Logowanie...<br/>";
$login->login(".....", ".....");
/*
* Errory are indexed like that:
* username => "error about username"
* password => "error about password"
* data => "error about data correctness"
*/
if ($login->hasErrors()) {
die(var_dump($login->getErrors()));
}
echo Login::getName() . "<br/>";
echo Login::getId() . "<br/>";
echo Login::getType() . "<br/>";
var_dump(Login::checkSession());
echo "<br/>";
var_dump(Login::getInfo());
echo "Logout...<br/>";
Login::logout();
var_dump(Login::checkSession());
exit;
echo "Next login...";
$login->login(".....", ".....");
var_dump(Login::checkSession());
}
catch(PDOException $e) {
echo "PDO library error occured: " . $e->getMessage();
}
?>
|