项目第一次版本提交
This commit is contained in:
BIN
user/.DS_Store
vendored
Normal file
BIN
user/.DS_Store
vendored
Normal file
Binary file not shown.
60
user/header.php
Normal file
60
user/header.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* 头部公用文件
|
||||
*/
|
||||
|
||||
/**
|
||||
* 数据库配置文件
|
||||
*/
|
||||
include '../config/config.inc.php';
|
||||
|
||||
/**
|
||||
* 查询用户信息
|
||||
*/
|
||||
$stmt = $pdo->prepare('SELECT id,username,integral,zc_time,sex,email FROM u_users where id= ?');
|
||||
$stmt->execute(array($_SESSION['user']['id']));
|
||||
if ($stmt->rowCount() > 0) {
|
||||
list($id, $username, $integral, $zc_time, $sex, $email) = $stmt->fetch(PDO::FETCH_NUM);
|
||||
$zc_time = date('Y-m-d', $zc_time);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<ol class="breadcrumb" align="center">
|
||||
<li><a href="index.php">用户主页</a></li>
|
||||
<li><a href="#">当前(<?php echo $integral; ?>)积分</a></li>
|
||||
<li><a href="xiao_user.php?id=<?php echo $id; ?>">模拟消费1积分</a></li>
|
||||
<li><a href="qian_user.php?id=<?php echo $id; ?>">积分签到</a></li>
|
||||
<li><a href="xiu_user.php?id=<?php echo $id; ?>">修改资料</a></li>
|
||||
<li><a href="loginout.php">退出登陆</a></li>
|
||||
</ol>
|
||||
|
||||
|
||||
<style>
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0
|
||||
}
|
||||
|
||||
#filter-comp, .vnav-wrapper {
|
||||
border: 1px solid #e8e8e8;
|
||||
background-color: #fff;
|
||||
padding: 0
|
||||
}
|
||||
|
||||
#filter-comp a, .vnav-wrapper a {
|
||||
padding: 10px;
|
||||
display: block;
|
||||
color: #777;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #e8e8e8
|
||||
}
|
||||
|
||||
#filter-comp a.active, #filter-comp a:hover, .vnav-wrapper a:hover, .vnav-wrapper li.active a {
|
||||
color: #1abc9c;
|
||||
border-left: 3px solid #1abc9c;
|
||||
padding: 10px 10px 10px 7px
|
||||
}
|
||||
|
||||
</style>
|
||||
73
user/index.php
Normal file
73
user/index.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 用户主页功能实现
|
||||
*/
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="renderer" content="webkit"><!--告诉360用极速模式-->
|
||||
<meta name="author" content="">
|
||||
<meta name="keywords" content="">
|
||||
<meta name="description" content="">
|
||||
<title>会员管理系统</title>
|
||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container" style="min-height:450px;">
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-9" align="center">
|
||||
<div class="panel panel-default" style="border-radius: 0">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-12" style="text-align: center">
|
||||
<img src="/static/img/noavatar_middle.gif"
|
||||
style="margin-left:auto;margin-right:auto;border-radius:70px;border:5px solid #1abc9c;">
|
||||
<div style="margin: 30px 0 20px 0;">
|
||||
<span class="h3"><?php echo $username; ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-offset-2 col-sm-7">
|
||||
<form class="form-horizontal" style="background: none">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">用户名</label>
|
||||
<div class="col-sm-7">
|
||||
<input class="form-control" value="<?php echo $username; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-4 control-label">邮 箱</label>
|
||||
<div class="col-sm-7">
|
||||
<input class="form-control" value="<?php echo $email; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include 'right.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
36
user/loginout.php
Normal file
36
user/loginout.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 用户退出功能实现
|
||||
*/
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 取出当前登陆用户名
|
||||
*/
|
||||
$username = $_SESSION['user']['username'];
|
||||
|
||||
/**
|
||||
* 清空session
|
||||
*/
|
||||
$_SESSION['user'] = array();
|
||||
|
||||
|
||||
//if (isset($_COOKIE[session_name()])) {
|
||||
// setcookie(session_name(), '', time() - 42000, '/');
|
||||
//}
|
||||
//
|
||||
|
||||
//session_destroy();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆 表示退出 并做退出标记
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php?action=out");
|
||||
}
|
||||
|
||||
65
user/qian_user.php
Normal file
65
user/qian_user.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户签到功能实现
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* 引入数据库配置文件
|
||||
*/
|
||||
include '../config/config.inc.php';
|
||||
|
||||
|
||||
/**
|
||||
* 签到逻辑
|
||||
*/
|
||||
if (isset($_GET['id'])) {
|
||||
$sql = "select id,integral from u_users WHERE 1=1 and id={$_GET['id']} ";
|
||||
$res = $pdo->query($sql);
|
||||
list($id, $integral) = $res->fetch(PDO::FETCH_NUM);
|
||||
|
||||
//获取今天日期 20180123
|
||||
$ymd = date('Ymd', time());
|
||||
//判断今天是否已经签到
|
||||
$sql = "select * from u_crows WHERE ymd={$ymd} and uid={$_GET['id']} ";
|
||||
$res = $pdo->query($sql);
|
||||
//没有签到 执行签到
|
||||
if ($res->rowCount() == 0) {
|
||||
//积分增加
|
||||
$integral += 1;
|
||||
//写入签到记录
|
||||
$stmt = $pdo->prepare('INSERT INTO u_crows ( uid,jf,ymd) VALUES (?,?,?)');
|
||||
$stmt->execute(array($_GET['id'], $integral, $ymd));
|
||||
//修改用户积分
|
||||
$stmt = $pdo->prepare('UPDATE u_users SET integral=? WHERE id=?');
|
||||
$stmt->execute(array($integral, $id));
|
||||
|
||||
if ($stmt->rowCount() > 0) {
|
||||
echo "<script>alert('签到成功!积分+1');window.location.href = 'index.php';</script>";
|
||||
} else {
|
||||
echo "<script>alert('签到失败,请稍后重试');window.location.href = 'index.php';</script>";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "<script>alert('不能重复签到');window.location.href = 'index.php';</script>";
|
||||
|
||||
}
|
||||
die();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
85
user/qiandao.php
Normal file
85
user/qiandao.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户签到记录功能实现
|
||||
*/
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* 引入数据库配置文件
|
||||
*/
|
||||
include '../config/config.inc.php';
|
||||
|
||||
/**
|
||||
* 查询签到记录
|
||||
*/
|
||||
$sql = "SELECT u_crows.id,u_crows.ymd,u_crows.jf,u_users.username FROM u_crows join u_users where u_crows.uid= u_users.id and u_users.id={$_SESSION['user']['id']} order by u_crows.id DESC ";
|
||||
$res = $pdo->query($sql);
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="renderer" content="webkit"><!--告诉360用极速模式-->
|
||||
<meta name="author" content="">
|
||||
<meta name="keywords" content="">
|
||||
<meta name="description" content="">
|
||||
<title>会员管理系统</title>
|
||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="container">
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-9" align="center">
|
||||
<div class="panel" style="border-radius: 0;min-height:450px;">
|
||||
<div class="panel-heading" style="background-color:#1abc9c;color:white;border-radius:0;">签到记录</div>
|
||||
<div class="panel-body">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th style="text-align: center;">用户名</th>
|
||||
<th style="text-align: center;">签到时间</th>
|
||||
<th style="text-align: center;">剩余积分</th>
|
||||
<th style="text-align: center;">增加积分</th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
while (list($id, $ymd, $jf, $username) = $res->fetch(PDO::FETCH_NUM)) {
|
||||
echo "<tr>";
|
||||
echo "<td style=\"text-align: center;\">$username</td>";
|
||||
echo "<td style=\"text-align: center;\"> $ymd</td>";
|
||||
echo "<td style=\"text-align: center;\">$jf</td>";
|
||||
echo "<td style=\"text-align: center;\">+1 </td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php include 'right.php'; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
14
user/right.php
Normal file
14
user/right.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
*右侧公用文件
|
||||
*/
|
||||
?>
|
||||
|
||||
<div class="col-sm-3" role="complementary">
|
||||
<nav class="vnav-wrapper">
|
||||
<ul>
|
||||
<li class="active"><a href="qiandao.php">签到记录</a></li>
|
||||
<li class="active"><a href="xiaofei.php">消费记录</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
54
user/xiao_user.php
Normal file
54
user/xiao_user.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户模拟消费1积分功能实现
|
||||
*/
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* 引入数据库文件
|
||||
*/
|
||||
include '../config/config.inc.php';
|
||||
|
||||
/**
|
||||
* 定义时间
|
||||
*/
|
||||
$ymd = time();
|
||||
|
||||
/**
|
||||
* 模拟消费逻辑
|
||||
*/
|
||||
if (isset($_GET['id'])) {
|
||||
$sql = "select id,integral from u_users WHERE 1=1 and id={$_GET['id']} ";
|
||||
$res = $pdo->query($sql);
|
||||
list($id, $integral) = $res->fetch(PDO::FETCH_NUM);
|
||||
if ($integral >= 1) {
|
||||
//积分减少
|
||||
$integral -= 1;
|
||||
$stmt = $pdo->prepare('UPDATE u_users SET integral=? WHERE id=?');
|
||||
$stmt->execute(array($integral, $id));
|
||||
if ($stmt->rowCount() > 0) {
|
||||
//写入消费记录
|
||||
$stmt = $pdo->prepare('INSERT INTO u_xiaos ( uid,jf,ymd) VALUES (?,?,?)');
|
||||
$stmt->execute(array($_GET['id'], $integral, $ymd));
|
||||
echo "<script>alert('消费成功!积分-1');window.location.href = 'index.php';</script>";
|
||||
} else {
|
||||
echo "<script>alert('消费失败,请稍后重试');window.location.href = 'index.php';</script>";
|
||||
}
|
||||
} else {
|
||||
echo "<script>alert('积分不足,请赚取积分');window.location.href = 'index.php';</script>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
83
user/xiaofei.php
Normal file
83
user/xiaofei.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户消费记录功能实现
|
||||
*/
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* 引入数据库链接配置文件
|
||||
*/
|
||||
include '../config/config.inc.php';
|
||||
|
||||
/**
|
||||
* 查询签到记录
|
||||
*/
|
||||
$sql = "SELECT u_xiaos.id,u_xiaos.ymd,u_xiaos.jf,u_users.username FROM u_xiaos join u_users where u_xiaos.uid= u_users.id and u_users.id={$_SESSION['user']['id']} order by u_xiaos.id DESC";
|
||||
$res = $pdo->query($sql);
|
||||
|
||||
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="renderer" content="webkit"><!--告诉360用极速模式-->
|
||||
<meta name="author" content="">
|
||||
<meta name="keywords" content="">
|
||||
<meta name="description" content="">
|
||||
<title>会员管理系统</title>
|
||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="container">
|
||||
<?php include 'header.php'; ?>
|
||||
<div class="row">
|
||||
<div class="col-sm-9" align="center">
|
||||
<div class="panel" style="border-radius: 0;min-height:450px;">
|
||||
<div class="panel-heading" style="background-color:#1abc9c;color:white;border-radius:0;">消费记录</div>
|
||||
<div class="panel-body">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th style="text-align: center;">用户名</th>
|
||||
<th style="text-align: center;">消费时间</th>
|
||||
<th style="text-align: center;">剩余积分</th>
|
||||
<th style="text-align: center;">扣除积分</th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
while (list($id, $ymd, $jf, $username) = $res->fetch(PDO::FETCH_NUM)) {
|
||||
$ymd = date('Y-m-d H:i:s', $ymd);
|
||||
echo "<tr>";
|
||||
echo "<td style=\"text-align: center;\">$username</td>";
|
||||
echo "<td style=\"text-align: center;\">$ymd</td>";
|
||||
echo "<td style=\"text-align: center;\">$jf</td>";
|
||||
echo "<td style=\"text-align: center;\">-1</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include 'right.php'; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
103
user/xiu_user.php
Normal file
103
user/xiu_user.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* 修改用户资料功能实现
|
||||
*/
|
||||
|
||||
/**
|
||||
* 开启session
|
||||
*/
|
||||
session_start();
|
||||
|
||||
/**
|
||||
* 开启检查用户是否登陆
|
||||
*/
|
||||
if (empty($_SESSION['user']['isUserLogin'])) {
|
||||
header("Location:../index.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* 引入数据库文件
|
||||
*/
|
||||
include '../config/config.inc.php';
|
||||
|
||||
/**
|
||||
* 查询用户资料
|
||||
*/
|
||||
if (isset($_GET['id'])) {
|
||||
$sql = "select id,username,password,integral,sex,email from u_users WHERE 1=1 and id={$_GET['id']} ";
|
||||
$res = $pdo->query($sql);
|
||||
list($id, $username, $password, $integral, $sex, $email) = $res->fetch(PDO::FETCH_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户新资料
|
||||
*/
|
||||
if (isset($_POST['btn'])) {
|
||||
$stmt = $pdo->prepare('UPDATE u_users SET username=?,password=?,sex=?,email=? WHERE id=?');
|
||||
$stmt->execute(array($_POST['username'], $_POST['password'], $_POST['sex'], $_POST['email'], $_POST['id']));
|
||||
if ($stmt->rowCount() > 0) {
|
||||
echo "<script>alert('修改资料成功!');window.location.href = 'loginout.php';</script>";
|
||||
} else {
|
||||
echo "<script>alert('修改资料失败')</script>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="renderer" content="webkit">
|
||||
<title>修改资料</title>
|
||||
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div>
|
||||
<div class="container">
|
||||
<?php include 'header.php'; ?>
|
||||
<h1 class="text-center">修改资料</h1>
|
||||
<hr/>
|
||||
<form method="post" action="xiu_user.php" style="width: 30%;margin-left: 35%;">
|
||||
<input type="hidden" name="id" value="<?php echo $id; ?>">
|
||||
<div class="form-group">
|
||||
<label>用户名</label>
|
||||
<input type="text" class="form-control" name="username" value="<?php echo $username; ?>">
|
||||
<span aria-hidden="true"></span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>邮箱</label>
|
||||
<input type="text" class="form-control" name="email" value="<?php echo $email; ?>">
|
||||
<span aria-hidden="true"></span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label>密码</label>
|
||||
<input type="text" class="form-control" name="password" value="<?php echo $password; ?>">
|
||||
<span aria-hidden="true"></span>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>性别</label>
|
||||
<select class="form-control" name="sex">
|
||||
<option <?php if ($sex == 1) { ?> selected="selected" <?php } ?> value="1">男</option>
|
||||
<option <?php if ($sex == 0) { ?> selected="selected" <?php } ?> value="0">女</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" name="btn" class="btn btn-success">确认修改</button>
|
||||
<a href="index.php" class="btn">返回</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user