thinkphp框架是一个免费的,开源,快速,简单的面向对象的轻量级PHP开发框架。

了解什么是thinkphp概述,thinkphp项目目录结构,thinkphp的控制器,视图,thinkphp项目构建流程,thinkphp配置,thinkphp的模型,熟悉内置模板引擎。

thinkphp框架的特点,是一个功能丰富的轻量级的PHP开发框架,让web应用开发更简单,,更快速。

特性:

类库导入,url模式,编译机制,查询语言,视图模型,分组模块,模板引擎,ajax支持,缓存机制。

thinkphp可以支持windows/unix服务器环境,可运行于包含apache,iis在内的多种web服务。下载thinkPHP:

ThinkPHP的目录结构

自动生成目录

项目目录部署方案

命名规范

项目构建流程

自动生成目录

项目目录部署方案

项目构建流程

ThinkPHP的配置

配置格式

调试配置

ThinkPHP的控制器

控制器

跨模块调用

1、模型的命名

2、实例化模型

3、属性访问

4、连接数据库

5、创建数据

6、连贯操作

7、CURD操作

<?php
$db = array (
'server' => 'localhost',
'port' => '3306',
'username' => 'root',
'password' => 'dada',
'database' => 'dada'
); $conn = @mysql_connect($db['server'].':'.$db['port'],$db['username'],$db['password']);
if (! $conn) {
echo "服务器不能连!" . mysql_error();
} else {
// 声明字符集
mysql_set_charset('utf8', $conn);
// 选择数据库
mysql_select_db($db['database'], $conn);
}
<?php
if (! isset ( $_SESSION )) {
session_start ();
}
if (! isset ( $_SESSION ['userName'] )) {
header ( "location:login.php" );
}
$userName = $_SESSION ['userName']; // 访问数据库,查询学生表指定学号的学生
require_once 'dbconfig.php';
if (! isset ( $_REQUEST ['id'] )) {
header ( "location:index.php" );
}
$id = $_REQUEST ['id'];
$sql = "select * from student where id = $id";
// exit($sql);
$result = mysql_query ( $sql );
$row = mysql_fetch_array ( $result )?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生信息</title>
</head>
<body>
<div align='right'>用户名:<?=$userName?> <a href='loginout.php'>退出登录</a></a>
</div>
<div align='center'>
<hr />
<h1>学生信息</h1>
<form action='editdo.php' method='post'>
<input type='hidden' name='id' value='<?=$row ['id']?>'/>
<table width=300>
<tr>
<td align='center'>学号</td>
<td><input type='text' name='studentId'
value='<?=$row ['studentId']?>' /></td>
</tr>
<tr>
<td align='center'>姓名</td>
<td><input type='text' name='name' value='<?=$row ['name']?>' /></td>
</tr>
<tr>
<td align='center'>班级</td>
<td><input type='text' name='className'
value='<?=$row ['className']?>' /></td>
</tr>
<tr>
<td align='center'>生日</td>
<td><input type='text' name='birthday'
value='<?=$row ['birthday']?>' /></td>
</tr>
<tr>
<td align='center'>性别</td>
<td>
<input type='radio' name='sex' value='男' <?=$row ['sex']=='男'?'checked':''?>>男 </input>
<input type='radio' name='sex' value='女' <?=$row ['sex']=='女'?'checked':''?>>女</input>
</td>
</tr>
<tr>
<td align='center'>民族</td>
<td><input type='text' name='nation' value='<?=$row ['nation']?>' /></td>
</tr>
<tr>
<td colspan=2 align='center'><input type='submit' value='确认修改' /></td>
</tr>
</table>
</form>
</div>
</body>
</html>
<?php
require_once 'dbconfig.php';
header ( "content-type:text/html;charset=utf-8" ); // 取表单数据
$id = $_REQUEST ['id'];
$studentId = $_REQUEST ['studentId'];
$name = $_REQUEST ['name'];
$className = $_REQUEST ['className'];
$birthday = $_REQUEST ['birthday'];
$sex = $_REQUEST ['sex'];
$nation = $_REQUEST ['nation']; // sql语句中字符串数据类型都要加引号,数字字段随便
$sql = "update student set studentId ='$studentId',name = '$name',className = '$className',birthday = '$birthday',sex ='$sex',nation='$nation' where id = $id";
if (mysql_query ( $sql )) {
echo "修改成功!!!<br/>";
echo "<a href='index.php'>回到主页</a>";
} else {
echo "修改失败!!!<br/>";
echo "<a href='index.php'>系统错误</a>";
}
<?php
if (! isset ( $_SESSION )) {
session_start ();
}
if (! isset ( $_SESSION ['userName'] )) {
header ( "location:login.php" );
}
$userName = $_SESSION ['userName'];
// 访问数据库,查询学生表
require_once 'dbconfig.php';
$sql = "select * from student";
$result = mysql_query ( $sql );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学生信息</title>
</head>
<body>
<div align='right'>用户名:<?=$userName?> <a href='loginout.php'>退出登录</a></a>
</div>
<hr />
<h1>学生信息</h1>
<table border=1>
<tr>
<th>学号</td>
<th>姓名</td>
<th>班级</td>
<th>生日</td>
<th>性别</td>
<th>民族</td>
<th>操作</th>
</tr>
<?php
while ( $row = mysql_fetch_array ( $result ) ) {
echo "<tr>";
echo "<td>" . $row ['studentId'] . "</td>";
echo "<td>" . $row ['name'] . "</td>";
echo "<td>" . $row ['className'] . "</td>";
echo "<td>" . $row ['birthday'] . "</td>";
echo "<td>" . $row ['sex'] . "</td>";
echo "<td>" . $row ['nation'] . "</td>";
echo "<td>" ."<a href=\"edit.php?id='". $row ['id'] ."'\">编辑</a></td>";
echo "</tr>";
}
?>
</table> </body>
</html>
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content= "text/html; charset=utf-8" >
</head> <body>
<h1>1606登录</h1>
<form name="form1" method= "post" action= "logindo.php" >
<table width="300" border= "0" align= "center" cellpadding= "2" cellspacing= "2" >
<tr>
<td width="150" ><div align= "right" >用户名:</div></td>
<td width="150" ><input type= "text" name= username ></td>
</tr>
<tr>
<td><div align="right" >密码:</div></td>
<td><input type="password" name= "passcode" ></td>
</tr> </table>
<p align="center" >
<input type="submit" name= "Submit" value= "登录" >
<input type="reset" name= "Reset" value= "重置" >
<a href='register.php'>注册</a>
</p>
</form>
</body>
</html>
<?php
header ( "content-type:text/html;charset=utf-8" );
if (! isset ( $_SESSION )) {
session_start ();
}
if (isset ( $_SESSION ['userName'] )) {
header ( "location:index.php" );
} elseif (! isset ( $_REQUEST ['username'] )) {
header ( "location:login.php" );
} else {
$username = $_POST ['username'];
$passcode = $_POST ['passcode']; //计算摘要
$password2 = sha1 ( $passcode ); require_once 'dbconfig.php';
// 根据用户名和密码去查询帐号表
$sql = "select * from user where username= '$username' and password='$password2'";
$result = mysql_query ( $sql, $conn );
if ($row = mysql_fetch_array ( $result )) {
$_SESSION ['userName'] = $username;
header ( "location:index.php" );
} else {
echo "<script>alert('用户名或密码错误!');</script>";
echo "用户名或密码错误!<br/>";
echo "<a href='login.php'>重新登陆</a>";
}
}
?>
<?php
if(!isset($_SESSION)){
session_start();
}
session_destroy();
header("location:login.php");
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1 align='center'>欢迎注册</h1>
<hr>
<form action="registerdo.php" method='post'>
<label>用户名:</label><input type='text' name='username' /> <label>密码:</label><input
type='text' name='password' /> <input type='submit' name='hh'
value='提交' />
</form>
</body>
</html>
<?php
require_once 'dbconfig.php';
header("content-type:text/html;charset=utf-8");
//取表单数据
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
$password2 = sha1($password); //sql语句中字符串数据类型都要加引号,数字字段随便
$sql = "INSERT INTO user(id, username, password, status) VALUES (null,'$username','$password2',1)";
//exit($sql); if(mysql_query($sql)){
echo "注册成功!!!<br/>";
echo "<a href='login.php'>去登录</a>";
}else{
echo "注册失败!!!<br/>";
echo "<a href='register.php'>重注册</a>";
}

结言

好了,欢迎在留言区留言,与大家分享你的经验和心得。

感谢你学习今天的内容,如果你觉得这篇文章对你有帮助的话,也欢迎把它分享给更多的朋友,感谢。

感谢!承蒙关照!您真诚的赞赏是我前进的最大动力!

PHP全栈学习笔记19的更多相关文章

  1. PHP全栈学习笔记18

    php基础知识,JavaScript,jQuery,ajax基础知识 linux基础知识,mysql数据库的基础与优化 程序设计,PHP框架基础知识,算法,逻辑思维,高并发 PHP基础知识 引用变量, ...

  2. PHP全栈学习笔记29

    前言 这一章主要讲一讲PHP的背景,优势,PHP的环境搭建,书写和调式简单的PHP代码,如何解决简单的PHP错误等. 目录结构 PHP简介 PHP是面向对象,指令式编程,设计者是 拉斯姆斯·勒多夫 出 ...

  3. PHP全栈学习笔记13

    php与ajax技术 web2.0的到来,ajax逐渐成为主流,什么是ajax,ajax的开发模式,优点,使用技术.(ajax概述,ajax使用的技术,需要注意的 问题,在PHP应用ajax技术的应用 ...

  4. PHP全栈学习笔记12

    php简介,php历史,php后端工程师职业前景,php技术方向,php后端工程师职业体系介绍. php是世界上使用最广泛的web开发语言,是超文本预处理器,是一种通用的开源脚本语言,语法吸收了c语言 ...

  5. PHP全栈学习笔记17

    phpmyadmin教程 管理页进入phpmyadmin 打开C:\wamp\apps\phpmyadmin3.5.1下的配置文件:config.inc 修改密码 创建与修改数据库.数据表 字段类型 ...

  6. PHP全栈学习笔记16

    <?php $fileName = "php大师.test.php"; //补充程序,显示文件名(不包括扩展名) $start = strrpos($fileName, &q ...

  7. PHP全栈学习笔记15

    PHP标记风格 PHP一共支持4种标记风格 <?php echo "这是XML风格的标记"; ?> 脚本风格 <script language="php ...

  8. PHP全栈学习笔记14

    一.搭建PHP开发环境 Apahce服务器 Dreamwear创建站点 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitiona ...

  9. PHP全栈学习笔记11

    连接MySQL mysql_connect(servername,username,password); 面向对象: <?php $servername = "localhost&qu ...

随机推荐

  1. C++ 构造函数_内存分区_对象初始化

    内存分区 栈区:int  x = 0:int  *p = NULL; 定义一个变量,定义一个指针时,会在栈区进行分配内存.分配的内存系统分配收回的,我们不用管. 堆区:int  *p = new  i ...

  2. QT 控制LED实验

    1.实验准备 在PC 机D:盘下创建文件夹qt-led,将光盘qt_led_exp 文件夹下的images 文件夹拷贝到E:盘下qt-led 文件夹qt-led 内 2.新建工程 新建一个Empty ...

  3. 初尝微信小程序开发与实践

    这可能是一个java程序员最不务正业的一次分享了. 小程序的火热相信不用我多说了,年初的时候老婆去浦东某达面试,甚至都被问有没有小程序测试经验.俨然小程序成为了互联网公司自PC,WAP,安卓,IOS之 ...

  4. python打造文件包含漏洞检测工具

    0x00前言: 做Hack the box的题.感觉那个平台得开个VIp 不然得凉.一天只能重置一次...mmp 做的那题毒药是文件包含漏洞的题,涉及到了某个工具 看的不错就开发了一个. 0x01代码 ...

  5. uva-10815-字符串排序

    又偷懒了,字符串排序,贱贱的用了std:map #include <iostream> #include <sstream> #include<algorithm> ...

  6. ADO Connection failure

    使用ado连接,频繁报错.为何?是网络的问题吗?太灵敏了.Connection failure. 跟大文本又关系??

  7. VB.Net条形码编程的方法

    一.条形码的读取用过键盘口式的扫条码工具的朋友就知道,它就如同在鍵盘上按下数字鍵一样,基本不需任何编程和处理.但如果你使用的是其它接口的话,可能你就要为该设备编写通讯代码了.以下有一段简单的25针串口 ...

  8. 跟我学算法-吴恩达老师(mini-batchsize,指数加权平均,Momentum 梯度下降法,RMS prop, Adam 优化算法, Learning rate decay)

    1.mini-batch size 表示每次都只筛选一部分作为训练的样本,进行训练,遍历一次样本的次数为(样本数/单次样本数目) 当mini-batch size 的数量通常介于1,m 之间    当 ...

  9. mac下的一个类似“_kbhit()”实现

    #include <sys/select.h> #include <termios.h> #include <sys/ioctl.h> int _kbhit() { ...

  10. 搭建双系统win10+ubuntu17.10

    0. 序言 这里采用先装win10,再装ubuntu的顺序.这样可以避免后面系统启动项设置的问题.都采用UEFI引导方式,且使用usb2.0的u盘来引导(3.0的话,要准备好3.0的驱动).另外注意的 ...