Advertisement
cecepsuwanda

contoh OOP

Jun 13th, 2016
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php      
  2.     class layout
  3.     {
  4.         public $action = '#';
  5.         public $method = 'post';
  6.         public $user = '';
  7.         public $pass = '';
  8.        
  9.         function from_login()
  10.         {
  11.             $tmp_txt =  "<form action='$this->action' method='$this->method'>";
  12.             $tmp_txt .=    "User name: <input type='text' name='fname'><br>";
  13.             $tmp_txt .=    "Password : <input type='password' name='lpass'><br>";
  14.            
  15.             if(!empty($this->user) and !empty($this->pass)){
  16.                $tmp_txt .= "User:$this->user Pass:$this->pass <br>";   
  17.             }      
  18.             $tmp_txt .= "<input type='submit' value='Login'></form>";          
  19.             return $tmp_txt;               
  20.         }
  21.     }
  22.  
  23. ?>
  24. <html>
  25.   <body>
  26.      <?php
  27.         $layout = new layout;
  28.        
  29.         if(isset($_POST['fname']) and isset($_POST['lpass']))
  30.         {
  31.           $layout->user=$_POST['fname'];
  32.           $layout->pass=$_POST['lpass'];     
  33.         }      
  34.         echo $layout->from_login();    
  35.      ?>
  36.   </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement