Advertisement
rav1989

Untitled

Apr 25th, 2011
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php
  2. try{
  3.     ob_start();
  4.     require('../class/sesja.php');
  5.  
  6.     if($session -> getUser() -> isAnonymous())
  7.     {
  8.  
  9.         if($_SERVER['REQUEST_METHOD'] == 'POST')
  10.         {
  11.             // Dane przyszly z formularza, czas je sprawdzic
  12.             $result = User::Rejestruj($_POST['login'], $_POST['haslo'], $_POST['nazwa']);
  13.                
  14.             if($result)
  15.             {
  16.                 $result = User::Sprawdz($_POST['login'], $_POST['haslo']);
  17.  
  18.                 if($result instanceof user)
  19.                 {
  20.                
  21.                 $session -> Update($result);
  22.                 echo 'Dziekujemy, zostales zarejestrowany <a href="index.php">Powrot</a>';
  23.                 }
  24.                 else
  25.                 {
  26.                     echo 'Nieprawidlowy login i/lub haslo!';
  27.                 }
  28.             }
  29.             else
  30.             {
  31.                 echo 'Ten user już istnieje!';
  32.             }
  33.         }
  34.         else
  35.         {
  36.             echo '<form method="post" action="./register.php">
  37.                 Nazwa: <input type="text" name="nazwa"/><br/>
  38.                 Login: <input type="text" name="login"/><br/>
  39.                 Haslo: <input type="password" name="haslo"/><br/>
  40.                 <input type="submit" value="Rejestruj"/>           
  41.                 </form>';      
  42.         }
  43.     }else{
  44.         header('Location: ./index.php');
  45.         exit;
  46.     }
  47.     ob_end_flush();
  48. }
  49. catch(PDOException $exception)
  50. {
  51.     echo 'Blad bazy danych: '.$exception->getMessage();
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement