Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1.  <?php
  2.  class authenticate
  3.  {
  4.     private $name;
  5.     private $password;
  6.    
  7.     public function login($name, $password)
  8.     {
  9.         $this->name = $name;
  10.         $this->password = $password;
  11.        
  12.         if($this->check())
  13.         {
  14.             echo "Onnistui!";
  15.         }
  16.         else
  17.         {
  18.             echo "OHO";
  19.         }
  20.     }
  21.    
  22.     protected function check()
  23.     {
  24.         if($this->name == "Miika")
  25.         {
  26.             if($this->password == "Salasana")
  27.             {
  28.                 $this->password = "";
  29.                 return true;
  30.             }
  31.         }
  32.         return false;
  33.     }
  34.    
  35.     public function identify()
  36.     {
  37.         echo "<br>".$this->name;
  38.         echo "<br>".$this->password;
  39.     }
  40.  
  41.  }
  42.  if(isset($_POST["login"]))
  43.  {
  44.     $logger = new authenticate();
  45.     $logger->login($_POST["name"], $_POST["password"]);
  46.     $logger->identify();
  47.  }
  48.  ?>
  49.  <form action="?" method="post">
  50.  Nimi:<br><input type="text" name="name"><br>
  51.  Salasana:<br><input type="text" name="password"><br>
  52.  <input type="submit" name="login" value="kirjaudu">
  53.  </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement