Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
REBOL 1.08 KB | None | 0 0
  1. //this is class.form.php
  2. <?php
  3. class formular {
  4.  
  5.     public function formStart($name,$method){
  6.        return '<form name="'.$name.'" method="'.$method.'">';
  7.     }
  8.  
  9.     public function inputText($name,$value){
  10.         return $value . ': <input type="text" name="'.$name.'" />';
  11.     }
  12.  
  13.     public function select($name,$array,$value){
  14.         $str='<select name="'.$name.'">';
  15.  
  16.         foreach ($array as $option) {
  17.             $str.='<option>'.$option.'</option>';
  18.         }
  19.        
  20.         $str.='</select>';
  21.  
  22.     return $str;
  23.     }
  24.  
  25.     public function submit($name){
  26.         return '<input type="submit" name="'.$name.'" value="'.$name.'" />';
  27.     }
  28.  
  29.     public function formslut(){
  30.         return '</form>';
  31.     }
  32. }
  33. ?>
  34.  
  35. //this is the index
  36.  
  37. <?php
  38. include('class.form.php');
  39.  
  40. $minForm = new formular();
  41.  
  42. echo $minForm->formStart("minForm", "POST");
  43. echo $minForm->inputText("navn", "Navn") . "<br />";
  44. $tal = array(0, 3, 7, 12, 34, 58);
  45. echo $minForm->select("tal", $tal, "Vælg tal") . "<br />";
  46. echo $minForm->submit("Send");
  47. echo $minForm->formslut();
  48.  
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement