一、更改默认控制器Index的代码,文件位置:www\Application\Home\Controller
源代码:
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$this->show(‘<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>!</p><br/>版本 V{$Think.version}</div><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_55e75dfae343f5a1"></thinkad><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>‘,‘utf-8‘);
}
}
更改完代码(目的是显示首页页面):
<?php
/*
User:shenlin
Time:2017-12-24
Purpose:会员系统首页
*/
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
//输出页面
$this->display();
}
}
二、显示页面、
页面保存位置:\Application\Home\View\Index,view目录下没有Index文件夹,需要自己新建文件夹名称,命名规则需要同控制器的名称。
三、编写首页代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>会员管理系统-首页</title>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
th{
text-align: center;
}
</style>
</head>
<body>
<!-- 页面简单编写,采用bootstrap框架 -->
<div class="container">
<div class="row">
<div class="col-md-2">
<h5>账号:13800000009</h5>
<h5><a href="">退出</a></h5>
</div>
<div class="col-md-10">
<h3><p class="text-center">会员首页</p></h3>
<table class="table table-striped table-bordered table-hover table-responsive">
<thead>
<tr>
<th>编号</th>
<th>登录账号</th>
<th>登录密码</th>
<th>名称</th>
<th>年龄</th>
<th>性别</th>
<th>居住地</th>
<th colspan="2">操作</th>
</tr>
</thead>
<tbody>
<!-- 信息 -->
<tr class="info">
<th>1</th>
<th>13800000002</th>
<th>*****</th>
<th>张三</th>
<th>23</th>
<th>1</th>
<th>沈阳</th>
<th>编辑</th>
<th>删除</th>
</tr>
<!-- 成功 -->
<tr class="success">
<th>2</th>
<th>13800000002</th>
<th>*****</th>
<th>张三</th>
<th>23</th>
<th>1</th>
<th>沈阳</th>
<th>编辑</th>
<th>删除</th>
</tr>
<!-- 危险 -->
<tr class="danger">
<th>3</th>
<th>13800000003</th>
<th>*****</th>
<th>张三</th>
<th>23</th>
<th>1</th>
<th>沈阳</th>
<th>编辑</th>
<th>删除</th>
</tr>
<!-- 隐藏行 通常测试使用 -->
<tr class="sr-only">
<th>4</th>
<th>13800000004</th>
<th>*****</th>
<th>张三</th>
<th>23</th>
<th>1</th>
<th>沈阳</th>
<th>编辑</th>
<th>删除</th>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
</html>
四、查看首页
