Thinkphp5.1 example of frame page Jump and modification of jump page template


In this paper, the example of thinkphp5.1 frame page Jump and modify the jump page template. To share with you for your reference, as follows:

Corresponding controller creates corresponding HTML

For example:

Admin (module) / LPP (controller) / index (method)

Corresponding HTML file:


1. Index.html layout

<form action="{:url('bbc')}" method="post">
<h3>User login interface</h3>
<input name="username" type="text"/>
  <input name="password" type="password"/>
  < input type = "submit" value = "login" / >
  < input type = "reset" value = "Cancel" >

2. Index () method:

public function index(){
  //Load page
  return view();

Index.html the method of jump processing data after inputting content

//Methods of post jump processing
public function bbc(){
  //Accept data (not visible in URL)
  $username = $_POST['username'];
  $password = $_POST['password'];
  //Judge the input information
  if ($username == 'admin' && $password == 'admin'){
    //If the jump address is not set, the previous page will be returned by default
    $this - > success ('login succeeded! ','Index/diaoyong');
    $this - > error ('wrong information! ).

3. Modify the template of the jump page

A. find the setting template location in the app.php file

B. file directory


C. data from the jump method to the template page

Echo $code. "< HR >"; -- returned status code 1 succeeded 0 failed
Echo $MSG. "< HR >"; -- prompt message of the page
Echo $wait. "< HR >"; -- waiting time
Echo $URL. "< HR >"; -- set the jump page to return to the previous page by default
Echo $data. "< HR >"; -- data returned by the user

D. skip to page template modification


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

Picture location: / static / xiao.jpg and / static / ku.jpg

E. self built template



For example: error.tpl

<!DOCTYPE html>
<html lang="en">
<meta charset=utf-8" />
< title > error! </title>
<link rel="stylesheet" href="" rel="external nofollow" >
        <?php echo $msg?>
        <img src="/static/ku.jpg" alt="" width="100%">
          Page auto < a href = "< PHP echo ($URL);? > rel =" external nofollow "> jump < / a > wait time: < b > < PHP echo ($wait);? ></b>
  <script type="text/javascript">
    var wait = document.getElementById('wait'),
      href = document.getElementById('href').href;
    var interval = setInterval(function(){
      var time = --wait.innerHTML;
      if(time <= 0) {
        location.href = href;
    }, 1000);

Picture preview:

For more information about ThinkPHP, readers who are interested in it can see the following topics: introduction to ThinkPHP, summary of operation skills of ThinkPHP template, summary of common methods of ThinkPHP, introduction to CodeIgniter, advanced tutorial of CI (CodeIgniter) framework, introduction to Zend framework and technical summary of PHP template.

I hope that this article will be helpful for you to design your PHP program based on the think PHP framework.

Recommended Today

[Redis5 source code learning] analysis of the randomkey part of redis command

baiyan Command syntax Command meaning: randomly return a key from the currently selected databaseCommand format: RANDOMKEY Command actual combat:> keys * 1) “kkk” 2) “key1”> randomkey “key1”> randomkey “kkk” Return value: random key; nil if database is empty Source code analysis Main process The processing function corresponding to the keys command is […]