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

首頁 > 語言 > PHP > 正文

ThinkPHP5.1框架頁面跳轉(zhuǎn)及修改跳轉(zhuǎn)頁面模版示例

2024-05-05 00:08:53
字體:
供稿:網(wǎng)友

本文實例講述了ThinkPHP5.1框架頁面跳轉(zhuǎn)及修改跳轉(zhuǎn)頁面模版。分享給大家供大家參考,具體如下:

對應(yīng)的控制器 創(chuàng)建對應(yīng)的HTML

比如:

admin(模塊)/lpp(控制器)/index(方法)

對應(yīng)的html文件:

view->lpp->index.html

1.index.html布局

<form action="{:url('bbc')}" method="post"><h3>用戶登錄界面</h3><p>UserName:<input name="username" type="text" id="001"/> </p><p>PassWord:  <input name="password" type="password" id="002"/></p><p>  <input type="submit" value="登錄"/>  <input type="reset" value="取消"></p></form>

2.index()方法:

public function index(){  //加載頁面  return view();}

index.html輸入內(nèi)容后跳轉(zhuǎn)處理數(shù)據(jù)的方法

//跳轉(zhuǎn)后處理的方法public function bbc(){  //接受數(shù)據(jù) (在URL中不可以被別人看見)  $username = $_POST['username'];  $password = $_POST['password'];  //判斷輸入的信息  if ($username == 'admin' && $password == 'admin'){    //跳轉(zhuǎn)地址未設(shè)置時,默認返回上一個頁面    $this->success('登錄成功!','Index/diaoyong');  }else{    $this->error('信息有誤!');  }}

3.修改跳轉(zhuǎn)頁面的模版

a、在app.php文件里面找到設(shè)置模版位置

b、文件目錄

C:/wamp/www/tp5/thinkphp/tpl/dispatch_jump.tpl

c、跳轉(zhuǎn)方法給模版頁面的數(shù)據(jù)

echo $code."<hr>"; --返回的狀態(tài)碼 1成功 0失敗echo $msg."<hr>";  --頁面的提示信息echo $wait."<hr>"; --等待的時間echo $url."<hr>";  --制定跳轉(zhuǎn)頁面 默認返回上一個頁面echo $data."<hr>"; --用戶返回的數(shù)據(jù)

d、跳轉(zhuǎn)頁面模版修改

C:/wamp/www/tp5/thinkphp/tpl/dispatch_jump.tpl

<?php switch ($code) {?>  <?php case 1:?>  <img src="/static/xiao.jpg"  <h1>:)</h1>  <p class="success"><?php echo(strip_tags($msg));?></p>  <?php break;?>  <?php case 0:?>  <img src="/static/ku.jpg"  <h1>:(</h1>  <p class="error"><?php echo(strip_tags($msg));?></p>  <?php break;?><?php } ?>

圖片位置:/static/xiao.jpg 和 /static/ku.jpg

e、自建模版

success.tpl

error.tpl

例如:error.tpl

<!DOCTYPE html><html lang="en"><head><meta charset=utf-8" /><title>錯誤!</title><link rel="stylesheet" href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="external nofollow" ></head><body>    <div class="container">    <div class="col-md-4"></div>    <div class="col-md-4">    <div class="panel panel-primary">      <div class="panel-heading">        <?php echo $msg?>      </div>      <div class="panel-body">        <img src="/static/ku.jpg"      </div>      <div class="panel-footer">        <p class="jump">          頁面自動 <a id="href" href="<?php echo($url);?>" rel="external nofollow" >跳轉(zhuǎn)</a> 等待時間: <b id="wait"><?php echo($wait);?></b>        </p>      </div>    </div>  </div>  </div>  <script type="text/javascript">  (function(){    var wait = document.getElementById('wait'),      href = document.getElementById('href').href;    var interval = setInterval(function(){      var time = --wait.innerHTML;      if(time <= 0) {        location.href = href;        clearInterval(interval);      };    }, 1000);  })();  </script></body></html>

圖片預(yù)覽:

ThinkPHP,頁面跳轉(zhuǎn),跳轉(zhuǎn)頁面模版

希望本文所述對大家基于ThinkPHP框架的PHP程序設(shè)計有所幫助。


注:相關(guān)教程知識閱讀請移步到PHP教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 镇康县| 德格县| 溆浦县| 清原| 巴林右旗| 三江| 福建省| 高尔夫| 鄂托克旗| 鹤岗市| 镇康县| 二手房| 安泽县| 沙河市| 陇西县| 新源县| 西宁市| 安福县| 青冈县| 东乡族自治县| 通河县| 湟中县| 高碑店市| 平武县| 二手房| 丰原市| 卓尼县| 庄浪县| 仁化县| 咸丰县| 太和县| 营口市| 平远县| 贺兰县| 太白县| 南乐县| 泸水县| 阜新| 隆子县| 确山县| 东方市|