02-php雇员管理系统-实现登录(连接数据库)
2013-08-12 16:15
786 查看
login.php
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="content-type">
</head>
<h1>管理员登录系统</h1>
<form action="loginProcess.php" method="post">
<table>
<tr>
<td>用户id</td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td>密 码</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><input type="submit" value="用户登录" /></td>
<td><input type="reset" value="重新填写" /></td>
</tr>
</table>
</form>
<?php
if(!empty($_GET['errno'])){
$errno=$_GET['errno'];
if($errno==1){
echo "<font color='red' size='3'>你的用户名或密码错误</font>";
}
}
?>
</html>
loginProcess.php
<?php
//接受用户的数据
//1.id
$id = $_POST ['id'];
//2.密码
$password = $_POST ['password'];
//得到连接
$conn = mysql_connect ( "localhost", "root", "root" );
if (! $conn) {
die ( "连接失败" . mysql_errno () );
}
//设置访问数据库的编码
mysql_query ( "set names utf8", $conn ) or die ( mysql_errno () );
//选择数据库
mysql_select_db ( "test", $conn ) or die ( mysql_errno () );
//发送sql语句验证
$sql = "select password from admin where id=$id";
//通过id获取password
$res = mysql_query ( $sql, $conn );
if ($row = mysql_fetch_assoc ( $res )) {
//取出数据库的密码
if ($row ['password'] == md5 ( $password )) {
header ( "Location:empManage.php" );
exit ();
}
}
header ( "Location:login.php?errno=1" );
exit ();
//关闭资源
mysql_free_result($res);
mysql_close($conn);
?>
empManage.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<?php
echo "登录成功!...";
echo "<br/><a href='login.php'>返回重新登录</a>";
?>
<h1>主界面</h1>
<a href="#">管理用户</a>
<br />
<a href="#">添加用户</a>
<br />
<a href="#">查询用户</a>
<br />
<a href="#">退出系统</a>
<br />
</html>
、
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="content-type">
</head>
<h1>管理员登录系统</h1>
<form action="loginProcess.php" method="post">
<table>
<tr>
<td>用户id</td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td>密 码</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td><input type="submit" value="用户登录" /></td>
<td><input type="reset" value="重新填写" /></td>
</tr>
</table>
</form>
<?php
if(!empty($_GET['errno'])){
$errno=$_GET['errno'];
if($errno==1){
echo "<font color='red' size='3'>你的用户名或密码错误</font>";
}
}
?>
</html>
loginProcess.php
<?php
//接受用户的数据
//1.id
$id = $_POST ['id'];
//2.密码
$password = $_POST ['password'];
//得到连接
$conn = mysql_connect ( "localhost", "root", "root" );
if (! $conn) {
die ( "连接失败" . mysql_errno () );
}
//设置访问数据库的编码
mysql_query ( "set names utf8", $conn ) or die ( mysql_errno () );
//选择数据库
mysql_select_db ( "test", $conn ) or die ( mysql_errno () );
//发送sql语句验证
$sql = "select password from admin where id=$id";
//通过id获取password
$res = mysql_query ( $sql, $conn );
if ($row = mysql_fetch_assoc ( $res )) {
//取出数据库的密码
if ($row ['password'] == md5 ( $password )) {
header ( "Location:empManage.php" );
exit ();
}
}
header ( "Location:login.php?errno=1" );
exit ();
//关闭资源
mysql_free_result($res);
mysql_close($conn);
?>
empManage.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<?php
echo "登录成功!...";
echo "<br/><a href='login.php'>返回重新登录</a>";
?>
<h1>主界面</h1>
<a href="#">管理用户</a>
<br />
<a href="#">添加用户</a>
<br />
<a href="#">查询用户</a>
<br />
<a href="#">退出系统</a>
<br />
</html>
、
相关文章推荐
- 07-php雇员管理系统-分层模式实现登录,分页
- 01-php项目之雇员管理系统1-实现登录功能
- 初学构建小项目之仓库管理系统数据库及表的创建及登录页面的实现(一)
- 05-php雇员管理系统-实现显示雇员信息列表分页
- 08-php雇员管理系统-分层模式实现通用分页
- php后台图书管理系统-登录页面02
- 【C#】C#连接数据库实现登录系统的功能
- 03-php雇员管理系统-实现显示用户名称
- PHP连接Mysql,实现基本的增、删、改、查——用户管理系统
- 我的第二行php代码之接受get请求连接数据库实现登录验证
- JDBC应用、控制台连MySQL接数据库实现学生管理系统的登录注册、增删改查
- 04-php雇员管理系统-实现显示雇员信息列表
- Java连接Oracle数据库开发银行管理系统【三、实现篇】
- “食面埋伏”餐饮管理系统设计与实现--JAVA开发涉及UI界面、POI、连接数据库
- 06-php雇员管理系统-实现显示雇员信息列表分页改进(可以处理大数据100000条)
- 安卓服务端开发(1) 安卓结合PHP实现连接数据库验证登录功能(附全部代码)
- jdbc连接Oracle数据库实现学生管理系统(用数据库连接池支持多用户操作同一数据库)
- PHP自学之路---雇员管理系统(2)
- php登录验证及代码实现 含数据库设计 亲测有效
- SpringBoot整合mybatis、shiro、redis实现基于数据库的细粒度动态权限管理系统实例