-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck.php
More file actions
50 lines (38 loc) · 1019 Bytes
/
check.php
File metadata and controls
50 lines (38 loc) · 1019 Bytes
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
<?php
//確認student_id是否正確
include_once('db.php');
include_once('html.php');
include_once('html_utility.php');
//用session傳遞student_id
session_start();
$MyHead = $_POST["MyHead"];
$_SESSION["student_id"] = $MyHead;
//取得student_id
$sql = "SELECT * FROM student where student_id = \"".$MyHead."\";";
$results_id = mysqli_query($conn, $sql) or die('MySQL query error');
//取得password
$password=$_POST["password"];
$sql = "SELECT * FROM student where student_password = \"".$password."\";";
$password_result = mysqli_query($conn, $sql) or die('MySQL query error');
$invalid_data = 0;
$errormsg = 'student_id or student_password is invalid !!';
if ($results_id->num_rows > 0 && $password_result->num_rows > 0) {
header("location: homepage.php");
} else {
$invalid_data = 1;
}
?>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<script>
window.alert("帳號/密碼輸入錯誤!");
window.location.href = "index.php";
</script>
</body>
</html>
<?php
$conn->close();
?>