win 7and mac开发自动化申领单Day2——工具Dreamweaver8+Xampp+PHP+Python+MySQL
1、把没写的知识点写上见http://www.cnblogs.com/uncle-guo/p/7670251.html
2、访问权限问题
思路:利用session==权限名称,跳转不同网页。
问题:其他人可以看,但是不能操作。即游客功能
login.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>
<?php
function login($username,$password)
{
session_start();
error_reporting(E_ALL &~ E_NOTICE); //屏蔽错误信息
include 'conn.php'; //调用数据库连接文件
if ($username == "" || $password == ""){ //判断用户名和密码是否为空
echo "<script>alert('请输入用户名和密码');history.back();</script>";
}
else
{
$selsql="SELECT * FROM admin WHERE user = '$username'";
$selres=$conn->query($selsql);
$selrow=mysqli_fetch_object($selres);
if ($selrow->user == $username)
{ //查询是否有此用户
if ($selrow->pwd == $password) //判断密码是否正确
{
$_SESSION["user_name"]=$selrow->name;
$_SESSION["code"]=mt_rand(0,100000);
$_SESSION["power"]=$selrow->power;
if($selrow->power=="大修发料")
{
?>
<script>
window.location.href="welcome-issues.php";
</script>
<?php
}
if($selrow->power=="检验")
{
?>
<script>
window.location.href="welcome-check.php";
</script>
<?php
}
}
else
{
echo "<script>alert('密码错误');history.back();</script>";
}
}
else
{
echo "<script>alert('用户不存在');history.back();</script>";
}
}
}
login($_POST['username'],$_POST['password']);//接收前台post值
?>
</body>
</html>
welcome-issues.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> <script type="text/javascript"> function showTime(){ nowtime=new Date(); year=nowtime.getFullYear(); month=nowtime.getMonth()+1; date=nowtime.getDate(); document.getElementById("mytime").innerText=year+"年"+month+"月"+date+"日"+"\n"+nowtime.toLocaleTimeString(); } setInterval("showTime()",1000); </script> </head> <body> <?php session_start(); if(isset($_SESSION["code"])){ ?> 欢迎:<?php echo "${_SESSION["user_name"]}"; ?><br /> 权限:<?php echo "${_SESSION["power"]}"; ?><br /> <span id="mytime"></span> <br/> <a href="login.html">退出登录</a> <?php } ?> </body> </html>
welcome-check.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> <script type="text/javascript"> function showTime(){ nowtime=new Date(); year=nowtime.getFullYear(); month=nowtime.getMonth()+1; date=nowtime.getDate(); document.getElementById("mytime").innerText=year+"年"+month+"月"+date+"日"+"\n"+nowtime.toLocaleTimeString(); } setInterval("showTime()",1000); </script> </head> <body> <?php session_start(); if(isset($_SESSION["code"])){ ?> 欢迎:<?php echo "${_SESSION["user_name"]}"; ?><br /> 权限:<?php echo "${_SESSION["power"]}"; ?><br /> <span id="mytime"></span> <br/> <a href="login.html">退出登录</a> <?php } ?> </body> </html>
3、研究框架: