PHP实现的简单留言板功能示例【基于thinkPHP框架】
ThinkPHP  /  管理员 发布于 7年前   605
本文实例讲述了PHP实现的简单留言板功能。分享给大家供大家参考,具体如下: 入口文件 文件名 index.php 配置文件 文件名 config.php 控制器 文件名 MsgController.class.php 模板 文件名 MsgModel.class.php 视图 文件名 addMsg.html 视图 文件名 index.html 视图 文件名 sendMsg.html 视图 文件名 upd.html 目录结构 数据库 sql语句 更多关于thinkPHP相关内容感兴趣的读者可查看本站专题:《ThinkPHP入门教程》、《thinkPHP模板操作技巧总结》、《ThinkPHP常用方法总结》、《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《Zend FrameWork框架入门教程》及《PHP模板技术总结》。 希望本文所述对大家基于ThinkPHP框架的PHP程序设计有所帮助。 5.3.0 !');// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为falsedefine('APP_DEBUG',True);//开发调试模式//define('APP_DEBUG',false);//生产模式// 定义应用目录define('APP_PATH','./Message/');// 引入ThinkPHP入口文件require './ThinkPHP/ThinkPHP.php';// 亲^_^ 后面不需要任何代码了 就是如此简单
'配置值' 'SHOW_PAGE_TRACE'=>true, 'DB_TYPE' => 'mysqli', // 数据库类型 'DB_HOST' => '127.0.0.1', // 服务器地址 'DB_NAME' => 'msg', // 数据库名 'DB_USER' => 'root', // 用户名 'DB_PWD' => 'root', // 密码 'DB_PORT' => '3306', // 端口 'DB_PREFIX' => 'ms_', // 数据库表前缀);
order('id DESC')->select(); $this->assign('info',$info); $this->display(); } public function sendMsg(){ $msg = new \Home\Model\MsgModel(); if (!empty($_POST)){ $data = $msg->create(); if($data){ $data['user_hobby'] = implode(',',$data['user_hobby']); $z = $msg->add($data); if ($z){ $this->redirect('Msg/sendMsg'); } }else{ $this->assign('errorInfo',$msg->getError()); } } $this->display(); } public function upd($id){ $msg = D('Msg'); if (!empty($_POST)){ $z = $msg->save($_POST); if ($z){ $this->redirect('index',array(),2,'修改成功'); }else{ $this->redirect('upd',array('id'=>$id),2,'修改失败'); } }else{ $info = $msg->find($id); $this->assign('info',$info); $this->display(); } } public function addMsg(){ $msg = D('Msg'); if (!empty($_POST)){ $z = $msg->add($_POST); if ($z){ $this->redirect('index',array(),2,'添加成功'); }else{ $this->redirect('addMsg',array(),2,'添加失败'); } }else{ $this->display(); } } public function del($id){ if(D('Msg')->delete($id)){ $this->success('成功',U('index'),2); }else{ $this->error('失败',U('index'),2); } }}
留言列表
添加
留言时间: {$vo.update_time|date="Y-m-d H:i:s",###} 留言人: {$vo.user} 标题: {$vo.title} 内容: {$vo.msg} 回复: {$vo.replay} 修改 删除
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;/*!40101 SET NAMES utf8 */;---- Y料: `msg`---- ------------------------------------------------------------ 表的Y `ms_msg`--CREATE TABLE IF NOT EXISTS `ms_msg` ( `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '主键', `admin_user` varchar(100) NOT NULL COMMENT '管理员', `update_time` int(10) NOT NULL COMMENT '更新时间', `status` int(2) NOT NULL COMMENT '状态', `send_msg_time` int(10) NOT NULL COMMENT '留言时间', `user` varchar(100) NOT NULL COMMENT '留言人', `title` varchar(100) NOT NULL COMMENT '标题', `msg` varchar(200) NOT NULL COMMENT '内容', `replay` varchar(200) NOT NULL COMMENT '回复', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='留言表' AUTO_INCREMENT=19 ;---- D存Y料表中的Y料 `ms_msg`--INSERT INTO `ms_msg` (`id`, `admin_user`, `update_time`, `status`, `send_msg_time`, `user`, `title`, `msg`, `replay`) VALUES(1, 'ms', 1479449110, 1, 1479449110, '1', '拉克丝的减肥', '对方科目了', 'NULL'),(7, '', 321423432, 0, 0, 'kljflwk', 'kjsdfnlk', 'nlkdsjfn', 'kljnf'),(3, 'ms', 1479451017, 1, 1479451017, '1', '轻松的发生我', '沃尔沃飞', 'NULL'),(8, 'ms', 1479544687, 1, 1479544687, '', 'qwe', '', 'NULL'),(9, 'ms', 1479544693, 1, 1479544693, 'qwe', 'qwe', 'qwe', 'NULL'),(10, 'ms', 1479544970, 1, 1479544970, 'qwe', 'qwe', 'qwe', 'NULL'),(11, 'ms', 1479544979, 1, 1479544979, '12', '12', '12', 'NULL'),(12, 'ms', 1479545029, 1, 1479545029, '12', '12', '12', 'NULL'),(13, 'ms', 1479546357, 1, 1479546357, '12', '12', '12', 'NULL'),(14, 'ms', 1479547163, 1, 1479547163, '12', '12', '12', 'NULL'),(16, 'ms', 1479547667, 1, 1479547667, '12', '12', '123', 'NULL'),(17, 'ms', 2147483647, 1, 1479547682, '上来昆明3', '说的了付款', '蓝山咖啡', '123213');/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
您可能感兴趣的文章:
122 在
学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..123 在
Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..博主 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..1111 在
佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
Copyright·© 2019 侯体宗版权所有·
粤ICP备20027696号