?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>emp用户登录1</title>
<h1>用户登录信息</h1>
<form action="loginProcess.php" method="post">
账 号:<input type="text" name="username"/></br></br>
密 码:<input type="password" name="password"></br></br>
<input type="submit" value="提交"/><input type="reset" value="重新填写"/></br></br>
</form>
</head>
<body>
</body>
</html>
<?php
if(!empty($_GET["errno"])){//怎么变为红色和重置表格信息
if($_GET["errno"]==1){
echo "<font color='red';>用户名或密码不对!</font>";}
}
?>
**************loginprocess******************
<?php
$username=$_POST["username"];
$password=md5($_POST["password"]);
$mysqli_client=new mysqli("localhost:", "root", "","news_db");
$mysqli_client->query("set names utf8");
$sql="select password,id from emp where username='$username'";
$result=$mysqli_client->query($sql);
if($row=$result->fetch_assoc()){
echo $row["password"]."-- ".$password;
if($row["password"]==$password){
//成功
echo "成功";
$id=$row["id"];
header("Location:empMain.php?id=$id");
}else{
echo "失败";
header("Location:login.php?errno=1");//用户或者密码不对
}// 失败
}
?>
***empMain
<?php
$user_id= $_GET["id"];
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>主页面</title>
</head>
<body>
<a href="userManage.php">管理用户1</a></br>
<a href="user_manage">管理用户2</a></br>
<a href="user_manage">管理用户3</a></br>
<a href="user_manage">管理用户4</a></br>
</body>
</html>
/***********usermanage******
<?php
//echo $user_id=$_GET['user_id'];
//搜索出用户id然后分页
$mysqli=new mysqli("localhost:3336", "root", "syb1871", "news_db");
$query="select count(*) from emp";
$res1=$mysqli->query($query) or die($mysqli->error);
$page_counts=0;//总记录数
if($row=$res1->fetch_row()){
$page_counts=$row[0];
}
$res1->free();
//每页的记录数
$page_size=4;
//总页数
$pages=ceil($page_counts/$page_size);
//当前页数
$page_current=1;
if(!empty($_GET["page_current"])){//如果有修改了页数就跳转到这里,重置页数
$page_current=$_GET["page_current"];
echo $page_current;
}
echo $page_current."bbb";
//上一页
if($page_current>1){
$page_pre=$page_current-1;
}
//下一页
if($page_current<$page_counts){
$page_next=$page_current+1;
}
//查询每一页的数据
$sql2="select id,username,password,salary from emp limit ".($page_current-1)*$page_size.",$page_size";
$res2=$mysqli->query($sql2);
echo "<table border='1px';borderColor='blue';ceilspacing='0px';>";
echo "<tr><th>id</th><th>username</th><th>password</th><th>saslary</th><th>编辑用户</th><th>删除用户</th></tr>";
while($row2=$res2->fetch_row()){
echo " <tr>";
echo "<td>".$row2[0]."</td>"."<td>".$row2[1]."</td>"."<td>".$row2[2]."</td>"."<td>".$row2[3]."</td>"."<td><a href=#>编辑</a></td>"."<td><a href=#>删除</a></td>";
echo " </tr>";
}
echo "</table>";
//关闭资源
$res2->free();
//上一页、1234567下一页 当前页、共多少页
echo "<a href=userManage.php?page_current=$page_pre>上一页</a> ";
for($i=1;$i<=$pages;$i++){
echo "<a href=userManage.php?page_current=$i>$i</a> ";
}
echo "<a href=userManage.php?page_current=$page_next>下一页</a> ";
echo "当前第".$page_current."页";
echo "\共".$pages."页 ";
?>