-
Notifications
You must be signed in to change notification settings - Fork 2
/
editUser.php
138 lines (138 loc) · 8.81 KB
/
editUser.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>编辑用户</title>
</head>
<body>
<?php
require_once 'inc/dbConn.php';
$userId = $_GET['id'];
//这是啥东东。。
date_default_timezone_set("PRC");
//读数据。。。
$sql = "SELECT * FROM users WHERE id=" . $userId;
$result = mysqli_query($conn, $sql);
if (!$result) {
printf("Error: %s\n", mysqli_error($conn));
exit();
}
$user = mysqli_fetch_array($result);
echo $sql;
?>
<form action="editDo.php" method="post">
<input type="hidden" name="user_id" value="<?php echo $user['id'] ?>"/>
<table width="444" border="1" align="center">
<tr>
<td>用户名</td>
<td><input type="text" name="user_name" size="10" value="<?php echo $user['username'] ?>"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="password" size="10" value="<?php echo $user['password'] ?>"></td>
</tr>
<tr>
<td>性别</td>
<td><input type="radio" name="sex" value="男"
<?php if ($user['sex'] == '1') echo "checked=\"checked\"" ?> /> 男<input type="radio" name="sex"
value="女" <?php if ($user['sex'] == '2') echo "checked=\"checked\"" ?>
/> 女
</td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" name="age" size="3" value="<?php echo $user['age'] ?>"></td>
</tr>
<tr>
<td>出生年月</td>
<td>
<!-- 1。取得年月日。2。相应的年月日。。。你懂的 -->
<?php
$birday_y = date('Y', strtotime($user['birthday']));
$birday_m = date('m', strtotime($user['birthday']));
$birday_d = date('d', strtotime($user['birthday']));
?>
<select name="birthday_y">
<option value="1980" <?php if ($birday_y == 1980) echo "selected=\"selected\""; ?> >1980</option>
<option value="1981" <?php if ($birday_y == 1981) echo "selected=\"selected\""; ?> >1981</option>
<option value="1982" <?php if ($birday_y == 1982) echo "selected=\"selected\""; ?> >1982</option>
<option value="1983" <?php if ($birday_y == 1983) echo "selected=\"selected\""; ?> >1983</option>
<option value="1984" <?php if ($birday_y == 1984) echo "selected=\"selected\""; ?> >1984</option>
<option value="1985" <?php if ($birday_y == 1985) echo "selected=\"selected\""; ?> >1985</option>
<option value="1986" <?php if ($birday_y == 1986) echo "selected=\"selected\""; ?> >1986</option>
<option value="1987" <?php if ($birday_y == 1987) echo "selected=\"selected\""; ?> >1987</option>
<option value="1988" <?php if ($birday_y == 1988) echo "selected=\"selected\""; ?> >1988</option>
<option value="1989" <?php if ($birday_y == 1989) echo "selected=\"selected\""; ?> >1989</option>
<option value="1990" <?php if ($birday_y == 1990) echo "selected=\"selected\""; ?> >1990</option>
</select>
年
<select name="birthday_m">
<option value="1" <?php if ($birday_m == 1) echo "selected=\"selected\""; ?> >1</option>
<option value="2" <?php if ($birday_m == 2) echo "selected=\"selected\""; ?> >2</option>
<option value="3" <?php if ($birday_m == 3) echo "selected=\"selected\""; ?> >3</option>
<option value="4" <?php if ($birday_m == 4) echo "selected=\"selected\""; ?> >4</option>
<option value="5" <?php if ($birday_m == 5) echo "selected=\"selected\""; ?> >5</option>
<option value="6" <?php if ($birday_m == 6) echo "selected=\"selected\""; ?> >6</option>
<option value="7" <?php if ($birday_m == 7) echo "selected=\"selected\""; ?> >7</option>
<option value="8" <?php if ($birday_m == 8) echo "selected=\"selected\""; ?> >8</option>
<option value="9" <?php if ($birday_m == 9) echo "selected=\"selected\""; ?> >9</option>
<option value="10" <?php if ($birday_m == 10) echo "selected=\"selected\""; ?> >10</option>
<option value="11" <?php if ($birday_m == 11) echo "selected=\"selected\""; ?> >11</option>
<option value="12" <?php if ($birday_m == 12) echo "selected=\"selected\""; ?> >12</option>
</select>
月
<select name="birthday_d">
<option value="1" <?php if ($birday_d == 1) echo "selected=\"selected\""; ?> >1</option>
<option value="2" <?php if ($birday_d == 2) echo "selected=\"selected\""; ?> >2</option>
<option value="3" <?php if ($birday_d == 3) echo "selected=\"selected\""; ?> >3</option>
<option value="4" <?php if ($birday_d == 4) echo "selected=\"selected\""; ?> >4</option>
<option value="5" <?php if ($birday_d == 5) echo "selected=\"selected\""; ?> >5</option>
<option value="6" <?php if ($birday_d == 6) echo "selected=\"selected\""; ?> >6</option>
<option value="7" <?php if ($birday_d == 7) echo "selected=\"selected\""; ?> >7</option>
<option value="8" <?php if ($birday_d == 8) echo "selected=\"selected\""; ?> >8</option>
<option value="9" <?php if ($birday_d == 9) echo "selected=\"selected\""; ?> >9</option>
<option value="10" <?php if ($birday_d == 10) echo "selected=\"selected\""; ?> >10</option>
<option value="11" <?php if ($birday_d == 11) echo "selected=\"selected\""; ?> >11</option>
<option value="12" <?php if ($birday_d == 12) echo "selected=\"selected\""; ?> >12</option>
<option value="13" <?php if ($birday_d == 13) echo "selected=\"selected\""; ?> >13</option>
<option value="14" <?php if ($birday_d == 14) echo "selected=\"selected\""; ?> >14</option>
<option value="15" <?php if ($birday_d == 15) echo "selected=\"selected\""; ?> >15</option>
<option value="16" <?php if ($birday_d == 16) echo "selected=\"selected\""; ?> >16</option>
<option value="17" <?php if ($birday_d == 17) echo "selected=\"selected\""; ?> >17</option>
<option value="18" <?php if ($birday_d == 18) echo "selected=\"selected\""; ?> >18</option>
<option value="19" <?php if ($birday_d == 19) echo "selected=\"selected\""; ?> >19</option>
<option value="20" <?php if ($birday_d == 20) echo "selected=\"selected\""; ?> >20</option>
<option value="21" <?php if ($birday_d == 21) echo "selected=\"selected\""; ?> >21</option>
<option value="22" <?php if ($birday_d == 22) echo "selected=\"selected\""; ?> >22</option>
<option value="23" <?php if ($birday_d == 23) echo "selected=\"selected\""; ?> >23</option>
<option value="24" <?php if ($birday_d == 24) echo "selected=\"selected\""; ?> >24</option>
<option value="25" <?php if ($birday_d == 25) echo "selected=\"selected\""; ?> >25</option>
<option value="26" <?php if ($birday_d == 26) echo "selected=\"selected\""; ?> >26</option>
<option value="27" <?php if ($birday_d == 27) echo "selected=\"selected\""; ?> >27</option>
<option value="28" <?php if ($birday_d == 28) echo "selected=\"selected\""; ?> >28</option>
<option value="29" <?php if ($birday_d == 29) echo "selected=\"selected\""; ?> >29</option>
<option value="30" <?php if ($birday_d == 30) echo "selected=\"selected\""; ?> >30</option>
<option value="31" <?php if ($birday_d == 31) echo "selected=\"selected\""; ?> >31</option>
</select>
日
</td>
</tr>
<tr>
<td>爱好</td>
<td><input type="text" name="hobby" size="44" value="<?php echo $user['hobby'] ?>"></td>
</tr>
<tr>
<td>个人简介</td>
<td><textarea name="profile" rows="10" cols="30"><?php echo $user['profile'] ?> </textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="确定修改"/></td>
</tr>
</table>
<p></p>
<p></p>
<p></p>
</form>
</body>
</html>