Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit f1ccbe0

Browse files
committed
update 2024.4.3
1 parent 3c2e43a commit f1ccbe0

File tree

8 files changed

+49
-4
lines changed

8 files changed

+49
-4
lines changed

core/UserCtrl.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public static function getCurrentUser(): User|null
3636
return null;
3737
}
3838

39+
public static function addUser($email, $password, $admin): bool
40+
{
41+
$conn = new ConnDB();
42+
return $conn->execute("INSERT INTO tb_users (email,password,admin) VALUES (?,?,?)", "ssi", $email, $password, $admin);
43+
}
44+
3945
public static function updateUser($id, $email, $password, $admin): bool
4046
{
4147
$conn = new ConnDB();
@@ -102,6 +108,15 @@ public static function login($email, $password, $keepLogin): bool
102108
return false;
103109
}
104110

111+
public static function registerAsStudent($email, $password): bool
112+
{
113+
return UserCtrl::addUser($email, $password, false);
114+
}
115+
public static function registerAsAdmin($email, $password): bool
116+
{
117+
return UserCtrl::addUser($email, $password, true);
118+
}
119+
105120
public static function logout()
106121
{
107122
return setcookie("login", "", time());

index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á</title>
8+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
89
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
910
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1011
</head>

student/index.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á</title>
8+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
89
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
910
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1011
<script src="/assets/jquery/jquery-3.7.1.min.js"></script>
@@ -139,7 +140,10 @@
139140
const majorList = [
140141
<?php
141142
foreach ($majorList as $major) {
142-
$studentHasWish = WishCtrl::studentHasWish($studentProfile->id, $major->id);
143+
$studentHasWish = false;
144+
if ($studentProfile !== null) {
145+
$studentHasWish = WishCtrl::studentHasWish($studentProfile->id, $major->id);
146+
}
143147
echo "{ majorId: " . $major->id . ", majorName: '" . $major->name . "', score: " . $major->score . ", studentHas: " . ($studentHasWish ? 1 : 0) . " },";
144148
}
145149
?>

student/login.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Đăng nhập | Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á</title>
8+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
89
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
910
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1011
</head>
@@ -22,8 +23,7 @@
2223
$keepLogin = true;
2324
}
2425

25-
$isLoggedIn = UserCtrl::login($email, $password, $keepLogin);
26-
if ($isLoggedIn) {
26+
if (UserCtrl::login($email, $password, $keepLogin)) {
2727
header("location: /student");
2828
exit();
2929
} else {

student/profile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Hồ sơ | Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á</title>
8+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
89
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
910
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1011
</head>

student/register.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,33 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Đăng ký | Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á</title>
8+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
89
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
910
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1011
</head>
1112

1213
<body>
14+
<?php
15+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
16+
require_once "../core/User.php";
17+
require_once "../core/UserCtrl.php";
18+
19+
$email = $_POST["email"];
20+
$password = $_POST["password"];
21+
$confirmPassword = $_POST["confirmPassword"];
22+
23+
if ($password == $confirmPassword) {
24+
if (UserCtrl::registerAsStudent($email, $password)) {
25+
echo "<script>alert('Đăng ký thành công');window.location.href='/student/login.php'</script>";
26+
} else {
27+
echo "<script>alert('Đăng ký không thành công')</script>";
28+
}
29+
} else {
30+
echo "<script>alert('Mật khẩu không trùng khớp')</script>";
31+
}
32+
}
33+
?>
34+
1335
<header class="text-primary p-3 mb-5 d-flex justify-content-center align-items-center">
1436
<img src="/assets/img/eaut_brand.webp" alt="Trường Đại học Công nghệ Đông Á" width="120" />
1537
<h3 class="m-0 ms-3 text-uppercase fw-bold">
@@ -23,7 +45,7 @@
2345
<h3 class="fw-bold text-center">ĐĂNG KÝ</h3>
2446
<p class="text-center text-primary mb-5">(với tư cách là học sinh)</p>
2547

26-
<form class="d-flex flex-column gap-3" action="/register.php" method="post">
48+
<form class="d-flex flex-column gap-3" action="/student/register.php" method="post">
2749
<label class="form-label fw-medium">
2850
Email <span class="text-danger">*</span>
2951
<input class="form-control" type="email" name="email" required />

student/user.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>
88
Tài khoản | Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á
99
</title>
10+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
1011
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
1112
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1213
</head>

student/wishlist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Nguyện vọng | Tuyển sinh đại học - Trường Đại học Công nghệ Đông Á</title>
8+
<link rel="icon" type="image/x-icon" href="/assets/img/eaut_brand.webp">
89
<link rel="stylesheet" href="/assets/bootstrap/bootstrap.min.css" />
910
<script src="/assets/bootstrap/bootstrap.bundle.min.js"></script>
1011
<script src="/assets/jquery/jquery-3.7.1.min.js"></script>

0 commit comments

Comments
 (0)