标签:登录界面 eth 通过 执行 hang 密码 src pre session
上一篇博文是新建流程,此篇是流程管理的后续内容:发起流程和审核流程
一. 发起流程和审核流程需要用到的三张表
二.写代码
1. 用ajax做了一个登录页面,用session获取用户名:
<!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" /> <script src="../jquery-3.2.0.min.js"></script> <title>无标题文档</title> </head> <body> <h1>登录页面</h1> <form action="dlchuli.php" method="post"> <div>用户名:<input type="text" id="uid" /></div> <div>密码:<input type="password" id="pwd" /></div> <input type="button" value="登录" id="btn" /> </form> </body> <script type="text/javascript"> //!!!用ajax之前一定先引用jqery $("#btn").click(function(){ //对登录按钮添加单击事件 var uid=$("#uid").val(); //获取用户的值 var pwd=$("#pwd").val(); //获取密码的值 $.ajax({ url:"dlchuli.php", //编写登录的处理页面 data:{uid:uid,pwd:pwd}, //将用户和密码传到处理页面 type:"POST", dataType:"TEXT", success: function(data) { if(data.trim()=="OK") { window.location.href="main.php"; //处理页面执行成功后,跳转到主页面 } else { alert("用户名或密码输入错误"); //否则就提示错误 } } }) }) </script> </html>
2.登录界面的处理页面 dlchuli.php
<?php session_start(); require "../DBDA.class.php"; $db = new DBDA(); //造新对象 //传过来的值 $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; //查询语句 $sql = " select pwd from users where uid=‘{$uid}‘ and pwd=‘{$pwd}‘"; //执行语句 $attr = $db->query($sql,1); if(!empty($pwd) && !empty($attr) && $attr[0][0]==$pwd) { $_SESSION["uid"] =$uid; //session接收用户值 echo "OK"; } else { echo "NO"; }
3.主页面 main.php
<!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> </head> <body> <h1>主页面</h1> <div><a href="faqi.php">发起流程</a> <a href="shenhe.php">审核流程</a></div> </body> </html>
4.发起流程页面 faqi.php
<!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> </head> <body> <h1>发起流程</h1> <form action="fqchuli.php" method="post"> <div>请选择发起的流程: <select name="lc"> <?php require "../DBDA.class.php"; $db = new DBDA(); $sql = "select * from liucheng"; $arr = $db->query($sql,1); foreach($arr as $v) { echo "<option value=‘{$v[0]}‘>{$v[1]}</option>"; } ?> </select> </div> <br /> <div> 请输入发起的内容:<textarea name="nr"></textarea> </div> <br /> <input type="submit" value="发起" /> </form> </body> </html>
5.发起流程处理页面 fqchuli.php
<?php session_start(); require "../DBDA.class.php"; $db = new DBDA(); $code =$_POST["lc"]; $nr =$_POST["nr"]; $uid = $_SESSION["uid"]; $time =date("Y-m-d H:i:s"); $sql = "insert into userflow values(‘‘,‘{$code}‘,‘{$uid}‘,‘{$nr}‘,0,‘{$time}‘,0)"; $db->query($sql); header("location:main.php");
点击“发起”,数据库中就会添加此条数据
6.流程审核页面 shenhe.php
<!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> </head> <body> <h1>流程审核页面</h1> <?php session_start(); $uid = $_SESSION["uid"]; require "../DBDA.class.php"; $db = new DBDA(); $sql = "select * from userflow a where code in(select code from flowpath where uids=‘{$uid}‘)
and towhere >=(select orders from flowpath b where b.code=a.code and b.uids=‘{$uid}‘ )" ; $arr = $db->query($sql,1); echo "<table width=‘100%‘ border=‘1‘ cellpadding=‘0‘ cellspacing=‘0‘> <tr> <td>流程代号</td> <td>发起者</td> <td>发起内容</td> <td>是否结束</td> <td>发起时间</td> <td>操作</td> </tr> "; foreach($arr as $v) { $zt = "<a href=‘tongguo.php?code={$v[0]}‘>通过</a>"; $sql = "select orders from flowpath where code=‘{$v[1]}‘ and uids=‘{$uid}‘"; $wz = $db->strquery($sql); if($v[6]>$wz) { $zt = "<span style=‘color:green‘>已通过</span>"; } echo "<tr> <td>{$v[1]}</td> <td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td>{$zt}</td> </tr>"; } echo "</table>"; ?> </body> </html>
7.写审核处理页面 tongguo.php(*)
<?php $ids = $_GET["code"]; require "../DBDA.class.php"; $db = new DBDA(); //让流程往下走,每审核通过一个,对应towhere字段要加1 $sql = "update userflow set towhere = towhere+1 where ids=‘{$ids}‘"; $db->query($sql); //判断流程是否结束 $sql = "select max(orders) from flowpath where code=( select code from userflow where ids=‘{$ids}‘)"; $maxsx = $db->strquery($sql); $sql = "select towhere from userflow where ids=‘{$ids}‘"; $towhere = $db->strquery($sql); if($towhere>$maxsx) { //如果结束了,修改状态 ;审核到最后时,对应的isok字段要变为1(此处1表示结束,0表示未结束) $sql = "update userflow set isok = 1 where ids=‘{$ids}‘"; $db->query($sql); } header("location:shenhe.php");
当写好这一步时,点击“通过”则会变成“已通过”;
zhangsan是第一个审核人,从zhangsan开始依次审核
niuniu是最后一个审核人,结束显示1
END
标签:登录界面 eth 通过 执行 hang 密码 src pre session
原文地址:http://www.cnblogs.com/zhaohui123/p/6906317.html