-
- //Form.php
-
- 수업 양식 {
-
- var $layout=true;// 테이블 레이아웃 사용 여부
-
- var $action;//양식을 제출할 URL
-
- var $method;
-
- var $enctype="";
-
- var $name="";
-
- var $id="";
-
- var $class="";
-
-
- 함수 형식( $action,$ method="POST"){ //생성자를 통해 멤버 변수 초기화
-
- $this->action=$action;
-
- $this->method=$method ;
-
- }
-
-
- 함수 form_start(){
-
- $text="n";
-
- }else {
-
- $text="n";
-
- }
-
- return $text;
-
- }
-
- //텍스트 상자 함수
-
- 함수 form_text($name,$id,$label_name, $label_for,$ value=""){
-
- $text="
- $text.="id ="{$ id}" ";
-
- if(isset($value)){
-
- $text.="value="{$value}" ";
-
- }
-
- $text.="/>n";
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item =$this- >form_item($label,$text);
-
- return $form_item;
-
- }
-
- //비밀번호 상자 기능
-
- 기능 form_passwd($name ,$id,$label_name,$label_for,$value=""){
-
- $text="
- $text.="id="{$id}" ";
-
- if(isset($value)){
-
- $text.="value="{ $value}" ";
-
- }
-
- $text.="/>n";
-
- $label=$this->form_label($label_name,$ label_for);
-
- $form_item=$this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- / /숨겨진 도메인 함수
-
- 함수 form_hidden($name,$id,$label_name,$label_for,$value=""){
-
- $text="
- if(isset($value)){
-
- $text.="value="{$value }" ";
-
- }
-
- $text.="/>n";
-
- $label=$this->form_label($label_name,$label_for) ;
-
- $form_item=$this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- //파일 도메인 함수
-
- 함수 form_file($name,$id,$label_name,$label_for,$size=""){
-
- $text="
- $text.="id="{$id}" ";
-
- if(isset($size)){
-
- $text.= "size="{$size}" ";
-
- }
-
- $text.="/>n";
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item=$ this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- //复选框函数
-
- 함수 form_checkbox ($name,$label=array(),$label_name,$label_for=""){
-
- $i=0;
-
- $text=array();
-
- foreach ($id=>$value로 $label){
-
- $text[$i]="";
-
- $text[$i].="
-
- $i ;
-
- }
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item=$this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- //单选框函数
-
- 함수 form_radio($name,$label=array(),$label_name,$label_for=""){
-
- $i=0;
-
- $text=array();
-
- foreach ($label as $id=>$value){
-
- $text[$i]="";
-
- $text[$i].="";
-
- $i ;
-
- }
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item=$this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- //下拉菜单函数
-
- 함수 form_select($id,$name,$options=array(),$selected=false,$label_name,$label_for,$onchange=""){
-
- if($onchange! ==""){
-
- $text="
-
- }
-
- else{
-
- $text="
-
- }
-
- foreach ($options as $value=>$key){
-
- if($selected==$value){
-
- $text.= "tn";
-
- }elseif ($selected===false) {
- $text.="tn";
-
- }
-
- }
-
- $text.="";
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item=$this-> form_item($label,$text);
-
- return $form_item;
-
- }
-
- //多选列表函数
-
- 함수 form_selectmul($id, $name,$size,$options=array(),$label_name,$label_for){
-
- $text="
-
- foreach ($options as $value=>$key){
-
- $text.="t< 옵션 값="{$value}">{$key}n";
-
- }
-
- $text.="n";
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item=$this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- //按钮函数
-
- function form_button($id,$name,$type,$value,$onclick=""){
-
- $text="n";
-
- if($this-> 레이아웃==true){
-
- $form_item="
nt | {$text} | n n";
-
- }else {
-
- $form_item=$text;
-
- }
-
- return $form_item;
-
- }
-
- //文本域函数
-
- 함수 form_textarea($id,$name,$cols,$rows,$label_name,$label_for,$value=""){
-
- $text=" n";
-
- $label=$this->form_label($label_name,$label_for);
-
- $form_item=$this->form_item($label,$text);
-
- return $form_item;
-
- }
-
- //文字标签函数
-
- function form_label($text,$for){
-
- if($for! ==""){
-
- $label="";
-
- }else {
-
- $label=$text.":";
-
- }
-
- return $label;
-
- }
-
-
- 함수 form_item($form_label,$form_text){
-
- 스위치($this->layout){
-
- true:
-
- $text="
n" ;
-
- $text.="t
";
-
- $text.=$form_label;
-
- $text.="< /th>n";
-
- $text.="t
";
-
- $text.=$form_text;
-
- $text.=" td>n";
-
- $text.="
| | n";
-
- break;
-
- 대소문자 false:
-
- $text= $form_label;
-
- $text.=$form_text;
-
- break;
-
- }
-
- return $text;
-
- }
-
-
- function CreateForm($form_item=array()){
-
- echo $this->form_start();
-
- foreach ($form_item을 $item으로){
-
- echo $item;
-
- }
-
- echo $this->form_end();
-
- }
-
- }
-
- ?>
复代码
-
-
-
-
-
- < ;link rel="stylesheet" type="text/css" href="css/styles.css" />
-
- 용户登录
-
- < ;/head>
-
-
-
- require_once("form.php");
-
- $form=새 양식 ($_SERVER['PHP_SELF']); //提交到本页
-
- $form->layout=false; //사용할 수 없는 表格布局, 大家可以把这句注释掉看结果가 없습니다
-
- $name=$form->form_text("userid","userid","용용 이름","userid ");
-
- $passwd=$form->form_passwd("passwd","passwd","密码","passwd");
-
- $submit=$form-> form_button("","submit","submit","登录");
-
- $form_item=array($name,$passwd,$submit);
-
- $form-> CreateForm($form_item);
-
- ?>
-
-
复system代码
|