This repository has been archived by the owner on Jul 28, 2020. It is now read-only.
forked from rainerosion/DormitoryRepair
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myhouse.php
224 lines (218 loc) · 6.68 KB
/
myhouse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?php
require 'config.php';
//mysqli连接
$mysqli = new mysqli($mysql_host,$mysql_user,$mysql_pwd,$mysql_db);
if($mysqli->connect_errno){
die('Connect Error:'.$mysqli->connect_error);
}
//设置编码
$mysqli->set_charset('utf8');
$verify_request = @$_COOKIE['verify_request'];
$postStr = pack("H*", $verify_request);
$postInfo = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, '这里改为AppSecret', $postStr, MCRYPT_MODE_CBC, '这里改为AppID');
$postInfo = rtrim($postInfo);
$postArr = json_decode($postInfo,true);
if($postArr['visit_user']['username'] == false){
die("<script>alert('请登录!');self.location = 'index.php';</script>");
}
?>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>宿舍在线报修系统</title>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
p{
text-indent:2em;
}
.panel-primary>.panel-heading{
color:#fff;
background-color: #00a65a;
border-color:#00a65a;
}
.navbar-inverse .navbar-nav >li>a:focus, .navbar-inverse .navbar-nav>li>a:hover{
background-color:transparent;
color: #fff;
}
.navbar-inverse{
background-color:#3c8dbc;
border-color:#3c8dbc;
color: #fff;
}
.navbar-inverse .navbar-nav>li>a{
color:#fff;
}
.navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover{
background-color: #3c8dbc;
}
.navbar-inverse .navbar-toggle {
border-color: #fff;
}
.col-md-8,.col-md-4{
padding-right:5px;
padding-left:5px;
}
.navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:focus, .navbar-inverse .navbar-nav>.open>a:hover {
color: #fff;
background-color: rgba(40, 98, 130, 0.32);
}
.navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:focus, .navbar-inverse .navbar-nav>.active>a:hover {
color: #fff;
background-color: rgba(40, 98, 130, 0.32);
}
.navbar-inverse .navbar-nav .open .dropdown-menu>li>a {
color: #c0dcd8;
}
.panel{
margin:0 auto;
max-width:700px;
}
.alert{
margin:0 auto;
margin-top:5px;
max-width:700px;
height:80px;
}
.div-img{
background-color: rgba(255, 255, 255, 0.3);
display: block;
padding: 10px;
}
.box-text {
border: 1px solid white;
color: blue;
font-style: italic;
width: 100%;
height: 100%;
}
.title-text {
font-size: 3.8em;
padding-top: 20px;
padding-bottom: 25px;
text-align: center;
}
.btn_form{
width:100%;
margin-top:4px;
}
.panel-title{
text-align:center;
}
.warning{
color: #8a6d3b;
border-radius:3px;
background-color: #fcf8e3;
border-color: #faebcc;
padding:13px;
}
.alert {
margin: 0 auto;
margin-top: 5px;
max-width: 700px;
height: auto;
}
*{
font-size:13px;
}
</style>
</head>
<body scrollTop="0">
<nav class="navbar navbar-inverse">
<div class="navbar-header">
<a href="index.php" class="navbar-brand">
<img src="./logo.png" height="20px" width="20px">
</a>
<button class="navbar-toggle collapsed" data-toggle="collapse" data-target="#mynavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="mynavbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="index.php"><span class="glyphicon glyphicon-calendar"></span> 我的报修</a></li>
<li><a href="submit.php"><span class="glyphicon glyphicon-edit"></span> 申请报修</a></li>
<li class="active"><a href="myhouse.php"><span class="glyphicon glyphicon-tags"></span> 我的宿舍</a></li>
<li><a href="question.php"><span class="glyphicon glyphicon-envelope"></span> 问题反馈</a></li>
</ul>
<!-- 导航条中的下拉菜单 -->
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span> <?php echo $postArr['visit_user']['username'].'(uid:'.$postArr['visit_user']['userid'].')';?></a>
<ul class="dropdown-menu">
<li><a href="index.php?act=login">登录</a></li> </ul>
</li>
</ul>
</div>
</nav>
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title">
设置基本用户信息
</div>
</div>
<div class="panel-body">
<div class="alert alert-warning">
特别注意!!!宿舍楼层和房间号码只能设置一次且不能修改。<b>房间号只需要输入3位纯数字宿舍号<b>.
</div>
<br />
<form class="form-horizontal" action="" method="POST">
<div class="form-group">
<label class="col-md-2 control-label">姓名:</label>
<div class="col-md-10">
<input class="form-control" name="name" type="text" value="" placeholder="真实姓名" required="required" >
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">房间:</label>
<div class="col-md-5">
<select class="form-control" name="floor">
<option value="A1">A1</option>
<option value="A2">A2</option>
<option value="A3">A3</option>
<option value="A4">A4</option>
<option value="A5">A5</option>
<option value="B1">B1</option>
<option value="B2">B2</option>
</select>
</div>
<div class="col-md-5">
<input class="form-control" name="room" type="text" value="" placeholder="房间号" required="required" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9]+/,'');}).call(this)" onblur="this.v();" />
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<div class="col-md-offset-2 col-md-10"><input id="submit" type="submit" name="submit" class="btn btn_form btn-primary" value="保存信息"> </div>
</div>
</div>
</form>
</div>
<div class="panel-footer">
Copyright © 2018 Powered By Rains
</div>
</div>
</div>
<?php
$uid = $postArr['visit_user']['userid']; //用户uid
$name = $_POST['name'];
$floor = $_POST['floor'];
$room = $_POST['room'];
if(@$_POST['submit'] == true){
$sql = "insert into `dorm_house` (ybuid,name,floor,room) values(?,?,?,?)";
//预处理
$mysqli_stmt=$mysqli->prepare($sql);
$mysqli_stmt->bind_param('issi',$uid,$name,$floor,$room);
//执行预处理语句
if($mysqli_stmt->execute()){
echo '<script>alert("设置成功");</script>';
}else{
echo '<script>alert("你已经设置过了");</script>';
}
}
?>
</body>
</html>