Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try{
- ob_start();
- require('../class/sesja.php');
- if($session -> getUser() -> isAnonymous())
- {
- if($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- // Dane przyszly z formularza, czas je sprawdzic
- $result = User::Sprawdz($_POST['login'], $_POST['haslo']);
- if($result instanceof user)
- {
- $session -> Update($result);
- echo 'Dziekujemy, zostales zalogowany jako '.
- $session -> getUser() -> getNazwa().'.
- <a href="./index.php">Powrot</a>';
- }
- else
- {
- echo 'Nieprawidlowy login i/lub haslo!';
- }
- }
- else
- {
- echo '<form method="post" action="./login.php">
- Login: <input type="text" name="login"/><br/>
- Haslo: <input type="password" name="haslo"/><br/>
- <input type="submit" value="Zaloguj"/>
- </form>';
- }
- }
- else
- {
- // Jezeli plik ten odpalony przez osobe zalogowana,
- // to ja wylogowujemy
- if($_GET['action'] == 'logout')
- {
- $session -> update(new user(true));
- header('Location: ./index.php');
- }else{
- header('Location: ./index.php');
- exit;
- }
- }
- ob_end_flush();
- }
- catch(PDOException $exception)
- {
- echo 'Blad bazy danych: '.$exception->getMessage();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement