------------------------------------------ add.php
------------------------------------------ add.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>郭老師資訊學園</title>
5 <meta charset="utf-8">
6 <link href="WebStyle.css" rel="stylesheet" type="text/css">
7 </head>
8 <body>
9 <header>
10 <h1>功能選單</h1>
11 <nav>修改密碼 線上測驗 療聊園地
12 </nav>
13 </header>
14 <section>
15 </section>
16 <article>
17 <form action="add.php" method="post">
18 <table>
19 <tr>
20 <td>年級</td>
21 <td>
22 <select name="gra" required>
23 <option value="">請選擇</option>
24 <option value="7">7</option>
25 <option value="8">8</option>
26 <option value="9">9</option>
27 </select>
28 </td>
29 <td>班級</td>
30 <td>
31 <select name="cla" required>
32 <option value="">請選擇</option>
33 <option value="01">01</option>
34 <option value="02">02</option>
35 <option value="03">03</option>
36 <option value="04">04</option>
37 <option value="05">05</option>
38 <option value="06">06</option>
39 <option value="07">07</option>
40 <option value="08">08</option>
41 <option value="09">09</option>
42 <option value="10">10</option>
43 <option value="11">11</option>
44 <option value="12">12</option>
45 <option value="13">13</option>
46 <option value="14">14</option>
47 <option value="15">15</option>
48 <option value="16">16</option>
49 <option value="17">17</option>
50 <option value="18">18</option>
51 <option value="19">19</option>
52 </select>
53 </td>
54 <td>座號</td>
55 <td>
56 <select name="sno" required>
57 <option value="">請選擇</option>
58 <option value="01">01</option>
59 <option value="02">02</option>
60 <option value="03">03</option>
61 <option value="04">04</option>
62 <option value="05">05</option>
63 <option value="06">06</option>
64 <option value="07">07</option>
65 <option value="08">08</option>
66 <option value="09">09</option>
67 <option value="10">10</option>
68 <option value="11">11</option>
69 <option value="12">12</option>
70 <option value="13">13</option>
71 <option value="14">14</option>
72 <option value="15">15</option>
73 <option value="16">16</option>
74 <option value="17">17</option>
75 <option value="18">18</option>
76 <option value="19">19</option>
77 <option value="20">20</option>
78 <option value="21">21</option>
79 <option value="22">22</option>
80 <option value="23">23</option>
81 <option value="24">24</option>
82 <option value="25">25</option>
83 <option value="26">26</option>
84 <option value="27">27</option>
85 <option value="28">28</option>
86 <option value="29">29</option>
87 </select>
88 </td>
89 </tr>
90 <tr>
91 <td>姓名</td>
92 <td>
93 <input name="na" type="text" required>
94 </td>
95 <td>密碼</td>
96 <td>
97 <input name="pwd" type="password" required>
98 </td>
99 </tr>
100 <tr>
101 <td>
102 </td>
103 </tr>
104 <tr>
105 <td>
106 <input type="submit" value="註冊資料" name="ok">
107
108 </td>
109
110 </tr>
111
112 </table>
113
114 </form>
115 </article>
116 <footer><p>Copyright © 2019 GuoChin All Rights Reserved</p></footer>
117 </body>
118 </html>
------------------------------------------ login.php
1 <?php
2 if (isset($_POST['pwd'])){
3 $conn=mysqli_connect("localhost","root","db123456","kkdb");
4
5 if (mysqli_connect_errno($conn))
6 die("無法連線!");
7
8 mysqli_set_charset($conn,"utf8");
9
10 $sql="SELECT * FROM tblstu WHERE gra='".$_POST['gra']."' AND cla='".$_POST['cla']."' AND sno='".$_POST['sno']."' AND pwd='".$_POST['pwd']."'";
11 $rslt=mysqli_query($conn,$sql);
12 $cnt=mysqli_num_rows($rslt);
13 if ($cnt>0){
14 header("Location:menu.html");
15 }
16 else{
17 ?>
18 <script language="javascript">;
19 alert("沒有註冊資料!請先註冊...");
20 window.location.href="add.html"
21 </script>;
22 <?php
23 // header("Location:add.html");
24 }
25 }
26 ?>
------------------------------------------ index.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>郭老師資訊學園</title>
5 <meta charset="utf-8">
6 <link href="WebStyle.css" rel="stylesheet" type="text/css">
7 </head>
8 <body>
9 <header>
10 <h1>同學登入</h1>
11 <nav>修改密碼 線上測驗 療聊園地
12 </nav>
13 </header>
14 <section>
15 </section>
16 <article>
17 <form action="login.php" method="post">
18 <table>
19 <tr>
20 <td>年級</td>
21 <td>
22 <select name="gra" required>
23 <option value="">請選擇</option>
24 <option value="7">7</option>
25 <option value="8">8</option>
26 <option value="9">9</option>
27 </select>
28 </td>
29 <td>班級</td>
30 <td>
31 <select name="cla" required>
32 <option value="">請選擇</option>
33 <option value="01">01</option>
34 <option value="02">02</option>
35 <option value="03">03</option>
36 <option value="04">04</option>
37 <option value="05">05</option>
38 <option value="06">06</option>
39 <option value="07">07</option>
40 <option value="08">08</option>
41 <option value="09">09</option>
42 <option value="10">10</option>
43 <option value="11">11</option>
44 <option value="12">12</option>
45 <option value="13">13</option>
46 <option value="14">14</option>
47 <option value="15">15</option>
48 <option value="16">16</option>
49 <option value="17">17</option>
50 <option value="18">18</option>
51 <option value="19">19</option>
52 </select>
53 </td>
54 <td>座號</td>
55 <td>
56 <select name="sno" required>
57 <option value="">請選擇</option>
58 <option value="01">01</option>
59 <option value="02">02</option>
60 <option value="03">03</option>
61 <option value="04">04</option>
62 <option value="05">05</option>
63 <option value="06">06</option>
64 <option value="07">07</option>
65 <option value="08">08</option>
66 <option value="09">09</option>
67 <option value="10">10</option>
68 <option value="11">11</option>
69 <option value="12">12</option>
70 <option value="13">13</option>
71 <option value="14">14</option>
72 <option value="15">15</option>
73 <option value="16">16</option>
74 <option value="17">17</option>
75 <option value="18">18</option>
76 <option value="19">19</option>
77 <option value="20">20</option>
78 <option value="21">21</option>
79 <option value="22">22</option>
80 <option value="23">23</option>
81 <option value="24">24</option>
82 <option value="25">25</option>
83 <option value="26">26</option>
84 <option value="27">27</option>
85 <option value="28">28</option>
86 <option value="29">29</option>
87 </select>
88 </td>
89 </tr>
90 <tr>
91 <td>密碼</td>
92 <td>
93 <input name="pwd" type="password" required>
94 </td>
95 </tr>
96 <tr>
97 <td>
98 <input type="submit" value="登入網站" name="ok">
99 </td>
100 </tr>
101 </table>
102 </form>
103 </article>
104 <footer><p>Copyright © 2019 GuoChin All Rights Reserved</p></footer>
105 </body>
106 </html>