国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > PHP > 正文

smarty和html_QuikForm聯(lián)合編程

2024-05-04 23:04:32
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

  折騰一個(gè)下午,把smarty和html_quikform聯(lián)結(jié)到一起了源碼:

test.php

<?php
      require_once "html/quickform.php";
      require_once 'html/quickform/renderer/arraysmarty.php';
      require_once 'link/myload.php';

      $form = new html_quickform('frmtest', 'get');
      $form->addelement('header', 'hdrtesting', 'smarty&html/quickform聯(lián)合編程實(shí)驗(yàn)');
      $form->addelement('text', 'txtfirstname', '貴姓?');
      $form->addelement('text', 'txtlastname', '尊名?');
      $form->addelement('text', 'txtage', '年齡?');
      $form->addelement('text', 'txttelephone', '電話(huà)?');
      $form->addelement('reset', 'btnclear', '復(fù)位');
      $form->addelement('submit', 'btnsubmit', '提交');
      if ($form->validate()) {
          # if the form validates then freeze the data
          $form->freeze();
      }

      // create the template object
      $tpl =$smarty=& new smarty_my;
    
            $tpl->compile_check = true;
      // create the renderer object   
      $renderer =& new html_quickform_renderer_arraysmarty($tpl);

      // build the html for the form
      $form->accept($renderer);

      // assign array with form data
      $tpl->assign('form_data', $renderer->toarray());

      // parse and display the template
      $tpl->display('my.tpl');

  ?>

mylink.php

<?php
// load smarty library
define('myclude',/usr/share/php/smarty');
require(myinclude.'/libs/smarty.class.php');

//setup.php是一個(gè)很好的加載應(yīng)用程序的類(lèi)庫(kù)文件(就是擴(kuò)展類(lèi))
//例如你可以在index文件里包含它

class smarty_my extends smarty {

   function smarty_my() {
  
           // class constructor. these automatically get set with each new instance.
//類(lèi)構(gòu)造函數(shù).創(chuàng)建實(shí)例的時(shí)候自動(dòng)配置
        $this->smarty();

        $this->template_dir = '/var/www/apache2-default/smarty/xsgl/templates/';
        $this->compile_dir = '/var/www/apache2-default/smarty/xsgl/templates_c/';
        $this->config_dir = '/var/www/apache2-default/smarty/xsgl/configs/';
        $this->cache_dir = '/var/www/apache2-default/smarty/xsgl/cache/';
       
        $this->caching = true;
        $this->assign('app_name','xsgl');
   }

}

模板文件my.tpl

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  <!--  $id: smarty-guide.tpl,v 1.1 2005/03/03 19:26:54 kae exp $ -->
 <head>
<link rel="stylesheet" type="text/css" href="css/my.css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
 
  </head>

  <body>
  <h2>
   
  </h2>
  <form >
    <!-- display the fields -->
    <table>
      <tr>
        <th></th>
        <td></td>
        <th></th>
        <td></td>
      </tr>
      <tr>
        <th></th>
        <td></td>
        <th></th>
        <td></td>
      </tr>
      <!-- display the buttons -->
      <tr>
        <td align="center" colspan="4">
          &nbsp;
        </td>
      </tr>
      <!-- display the copyright -->
      <tr>
        <td colspan="4">
          &copy;2005 陳剛 實(shí)驗(yàn)
        </td>
      </tr>
    </table>

  層疊式樣表文件my.css

body {
    background-color: #10f2e7;
}

 table  
n {
    font-size: small;
    font-family: arial, helvetica, sans-serif;
}
table {
    overflow: scroll;
    margin: 0.1px;
    font-weight: lighter;
    font-family: arial, helvetica, sans-serif;
}

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 靖远县| 崇阳县| 文昌市| 神农架林区| 昌黎县| 巴东县| 钟山县| 嘉荫县| 建瓯市| 鄂托克旗| 黑河市| 淮滨县| 达拉特旗| 来宾市| 苍梧县| 卓资县| 兖州市| 综艺| 府谷县| 迁西县| 区。| 鸡泽县| 镇原县| 陆丰市| 盐亭县| 余江县| 西贡区| 精河县| 霸州市| 永安市| 晴隆县| 正镶白旗| 盐边县| 朝阳县| 逊克县| 四子王旗| 峨眉山市| 通江县| 栾城县| 津市市| 陕西省|