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::Rejestruj($_POST['login'], $_POST['haslo'], $_POST['nazwa']);
- if($result)
- {
- $result = User::Sprawdz($_POST['login'], $_POST['haslo']);
- if($result instanceof user)
- {
- $session -> Update($result);
- echo 'Dziekujemy, zostales zarejestrowany <a href="index.php">Powrot</a>';
- }
- else
- {
- echo 'Nieprawidlowy login i/lub haslo!';
- }
- }
- else
- {
- echo 'Ten user już istnieje!';
- }
- }
- else
- {
- echo '<form method="post" action="./register.php">
- Nazwa: <input type="text" name="nazwa"/><br/>
- Login: <input type="text" name="login"/><br/>
- Haslo: <input type="password" name="haslo"/><br/>
- <input type="submit" value="Rejestruj"/>
- </form>';
- }
- }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