-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_index.php
More file actions
159 lines (145 loc) · 5.34 KB
/
admin_index.php
File metadata and controls
159 lines (145 loc) · 5.34 KB
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
<?php
//session_start();
header("content-type:text/html;charset=utf-8");
//连接数据库
$link = mysqli_connect("localhost", "root", "", "bjiu");
if (!$link) {
die("连接失败: " . mysqli_connect_error());
}
//接收表名
$tablename = "ord_detail";
//查看属性名
$_sql = "DESC $tablename";
$_result = mysqli_query($link, $_sql);
$_num = mysqli_num_rows($_result);
$arr[0] = '12';
$type[0] = '12';
//获取属性名
for ($i = 0; $i < $_num; $i++) {
$row = $_result->fetch_assoc();
$arr[$i] = $row["Field"];
$type[$i] = $row["Type"];
}
$_arr[0] = '12';
for ($i = 0; $i < $_num; $i++) {
$_arr[$i] = $_POST[$arr[$i]];
}
$rowname = '12';
if (strpos($type[0], 'char') !== false) {
$rowname = "'" . $_arr[0] . "'";
} else if (strpos($type[0], 'int') !== false) {
$rowname = (int)$_arr[0];
} else if (strpos($type[0], 'decimal') !== false) {
$rowname = (float)$_arr[0];
} else if (strpos($type[0], 'datetime') !== false) {
$rowname = "'" . $_arr[0] . "'";
}
//添加数据
$_sql = "insert into $tablename ($arr[0]) values ($rowname)";
$result = mysqli_query($link, $_sql);
if ($result) {
for ($i = 1; $i < $_num; $i++) {
if (strpos($type[$i], 'char') !== false) {
$_sql = "update $tablename set $arr[$i] = '$_arr[$i]' where $arr[0]=$rowname ";
$_result = mysqli_query($link, $_sql);
} else if (strpos($type[$i], 'int') !== false) {
$temp = (int)$_arr[$i];
$_sql = "update $tablename set $arr[$i] = $temp where $arr[0]=$rowname ";
$_result = mysqli_query($link, $_sql);
} else if (strpos($type[$i], 'decimal') !== false) {
$temp = (float)$_arr[$i];
$_sql = "update $tablename set $arr[$i] = $temp where $arr[0]=$rowname ";
$_result = mysqli_query($link, $_sql);
} else if (strpos($type[$i], 'datetime') !== false) {
$_sql = "update $tablename set $arr[$i] = '$_arr[$i]' where $arr[0]=$rowname ";
$_result = mysqli_query($link, $_sql);
}
}
}
mysqli_close($link); //关闭数据库
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>添加完成</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
flex-direction: column;
}
h3 {
color: #333;
}
form {
display: flex;
justify-content: center;
margin-top: 20px;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
margin: 8px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">慈善管理系统</a>
</div>
<div>
<ul class="nav navbar-nav">
<li class="active"><a href="admin_index.php">主页</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">捐赠机构管理<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="admin_charity.php">全部捐赠机构</a></li>
<li><a href="admin_charity_add.php">新增捐赠机构</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">捐赠者管理<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="admin_donor.php">全部捐赠者</a></li>
<li><a href="admin_donor_add.php">新增捐赠者</a></li>
</ul>
</li>
<li><a href="admin_logs.php">操作日志管理</a></li>
<li><a href="admin_repass.php">密码修改</a></li>
<li><a href="index.php">退出</a></li>
</ul>
</div>
</div>
</nav>
<?php
if ($result) {
echo '<h3>购买成功</h3>';
echo '<form action="check2.php" method="post">
<button type="submit" name="tablename" value="' . $tablename . '">返回</button>
</form>';
} else {
echo '<h3>购买失败</h3>';
echo '<form action="check2.php" method="post">
<button type="submit" name="tablename" value="' . $tablename . '">返回</button>
</form>';
}
?>
</body>
</html>