概述
登陆控制器与显示页面
<?php namespace AdminController; use ThinkController; class DengController extends Controller { function denglu() { $this->display(); } function dengluchuli() { $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $n = D("yuangong"); $attr = $n->find("$uid"); $mm = $attr['password']; $name = $attr['name']; if(!empty($pwd) && $pwd!="") { if($pwd!=$mm) { $this->ajaxReturn("密码或账号错误","eval"); } else { session('uid',$uid); session('name',$name); $this->ajaxReturn("OK","eval"); } } else { $this->ajaxReturn("请输入密码","eval"); } } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="__PUBLIC__/js/jquery-1.11.2.min.js"></script> </head> <body> <div>账号:<input id="uid" type="text" /></div> <div>密码:<input id="pwd" type="text" /></div> <div><input id="btn" type="button" value="提交" /></div> </body> <script type="text/javascript"> $(document).ready(function(e) { $("#btn").click(function(){ var uid = $("#uid").val(); var pwd = $("#pwd").val(); $.ajax({ url:"__CONTROLLER__/dengluchuli", data:{uid:uid,pwd:pwd}, dataType:"TEXT", type:"POST", success:function(data){ if(data=="OK") { window.location.href="__MODULE__/Zhu/zhu"; } else { alert(data); } } }); }) }); </script> </html> </html>
父级控制器
<?php namespace AdminController; use ThinkController; class FuController extends Controller { //构造函数 public function __construct() { parent::__construct(); if(session('?uid')) //判断uid是否登陆 { } else { $this->redirect("Admin/Deng/denglu", array(), 3, '请登录...'); //没有登录就跳转回登陆页面 exit; } } }
主页控制器与显示页面
<?php namespace AdminController; use AdminControllerFuController; class ZhuController extends FuController { public function zhu() { $this->display(); } public function xianshi() { $uid = session('uid'); $n = D("yuangong"); $attr = $n->find("$uid"); $name = $attr['name']; $n = D("liuyan"); $attr = $n->where("Recever='$name' OR Recever='所有人'")->select(); $this->ajaxReturn($attr); //ajax返回方法 } public function qingchu() { session(null); $this->redirect("Admin/Deng/denglu", array(), 1, '退出中...'); exit; } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="__PUBLIC__/js/jquery-1.11.2.min.js"></script> </head> <body> <table id="aa" width="100%" border="1" cellpadding="0" cellspacing="0"> </table> <a href="__MODULE__/Liu/liuyan">发布信息</a> <a href="__MODULE__/Zhu/qingchu">退出程序</a> </body> <script type="text/javascript"> $(document).ready(function(e) { $.ajax({ url:"__CONTROLLER__/xianshi", data:{}, type:"POST", dataType:"JSON", success: function(data){ var aa = "<tr><td>发件人</td><td>接收人</td><td>发送时间</td><td>内容</td></tr>"; var str = ""; for(a in data) { str = str+"<tr><td>"+data[a].sender+"</td><td>"+data[a].recever+"</td><td>"+data[a].times+"</td><td>"+data[a].comment+"</td></tr>"; } $("#aa").html(aa+str); } }) }); </script> </html>
发信控制器与显示页面
<?php namespace AdminController; use AdminControllerFuController; class LiuController extends FuController { public function liuyan() { $this->display(); } public function tianjia() { /*$jsr = $_POST["jsr"]; $nr = $_POST["nr"]; $sj = date("y-m-d H-i-s"); $fjr = session('uid');*/ $m = M("liuyan"); $data['Ids'] = ''; $data['Sender'] = session('name'); $data['Recever'] = $_POST["jsr"]; $data['Times'] = date("y-m-d H-i-s"); $data['Comment'] = $_POST["nr"]; $data['States'] = ""; $m->add($data); /*$value = session('name'); $this->ajaxReturn($value); */ } }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script src="__PUBLIC__/js/jquery-1.11.2.min.js"></script> </head> <body> <div>接收人:<input id="jsr" type="text" /></div> <div>内容:<input id="nr" type="text" /></div> <div><input id="btn" type="button" value="提交" /></div> <a href="__MODULE__/Zhu/zhu">查看信息</a> <a href="__MODULE__/Zhu/qingchu">退出程序</a> </body> <script type="text/javascript"> $(document).ready(function(e) { $("#btn").click(function(){ var jsr = $("#jsr").val(); var nr = $("#nr").val(); $.ajax({ url:"__CONTROLLER__/tianjia", data:{jsr:jsr,nr:nr}, dataType:"TEXT", type:"POST", success:function(data){ } }); }) }); </script> </html> </html>
转载于:https://www.cnblogs.com/bilibiliganbei/p/6219455.html
最后
以上就是酷酷老鼠为你收集整理的tp框架之留言板练习的全部内容,希望文章能够帮你解决tp框架之留言板练习所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复