Skip to content
Snippets Groups Projects
Commit ae575867 authored by CXM's avatar CXM
Browse files

Change some Chinese into English.

parent 75e72784
No related branches found
No related tags found
No related merge requests found
<?php
require_once '../Logic/config.php';
// 检查是否有POST请求提交表单
// Check if there is a POST request to submit the form
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// 处理表单提交的数据
// Processing data submitted by the form
if ($_POST["formType"] == "loginForm") {
session_start(); // 启动会话
session_start(); // start a session
// 表单中获取的用户名和密码和学生id
// Username and password and student id retrieved from the form
$username = $_POST['username'];
$studentId = $_POST['studentId'];
$password = $_POST['password'];
......@@ -16,26 +16,26 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt->execute();
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
// 遍历所有用户
// Iterate over all users
$loggedIn = false;
foreach ($users as $user) {
// 检查用户名和密码是否匹配
// Check that the username and password match
if ($user['account'] === $username && $user['password'] === $password) {
// 检查用户ID是否匹配
// Checking for user ID matches
if ($user['id'] == $studentId) {
// 登录成功,执行相应操作
$_SESSION['user_id'] = $user['id']; // 将用户 ID 存储在会话中
$_SESSION['user_type'] = $user['user_Type']; //储存用户类型
// Login successfully, perform the corresponding operation
$_SESSION['user_id'] = $user['id']; // Storing user IDs in the session
$_SESSION['user_type'] = $user['user_Type']; //Storage user type
// 更新用户的在线状态为 'online'
// Update user's online status to 'online'
$updateOnlineStatus = DB->prepare("UPDATE user SET is_online = 'online' WHERE id = ?");
$updateOnlineStatus->execute([$user['id']]);
$loggedIn = true;
break; // 退出循环
break; // exit cycle
} else {
// 用户名和密码匹配,但用户ID不匹配
echo "<script>alert('学生账号不在数据库中,请重试');</script>";
// Username and password match, but user ID does not match
echo "<script>alert('Student account is not in the database, please try again');</script>";
echo "<script>window.location.href = 'LoginPage.php';</script>";
}
}
......@@ -48,7 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit; // 结束脚本执行
} else {
// 登录失败,显示提示消息
echo "<script>alert('用户名或密码错误,请重试');</script>";
echo "<script>alert('Username or password is wrong, please try again');</script>";
echo "<script>window.location.href = 'LoginPage.php';</script>";
}
......
......@@ -11,7 +11,7 @@
<body>
<!-- 在线用户列表容器 -->
<div id="sidebar">
<h2>在线用户:</h2>
<h2>Online Users:</h2>
<ul id="online-users-list">
<!-- 在线用户将在这里列出 -->
</ul>
......
......@@ -21,14 +21,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if ($existingUser) {
// 学生已存在,提示用户已注册
echo "<script>alert('您已注册');</script>";
echo "<script>alert('You are already registered');</script>";
echo "<script>window.location.href = 'LoginPage.php';</script>";
exit;
}
//判断密码是否相同
if ($password != $confirm_password) {
echo "<script>alert('密码与确定密码不匹配!');</script>";
echo "<script>alert('The password does not match the OK password!');</script>";
echo "<script>window.location.href = 'register.php';</script>";
exit;
}
......@@ -60,7 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// 循环结束后,检查是否找到匹配的学生
if (!$match) {
// 注册失败,显示提示消息
echo "<script>alert('抱歉,您不是本校学生/老师');</script>";
echo "<script>alert('Sorry, you are not a student/teacher at this school');</script>";
echo "<script>window.location.href = 'register.php';</script>";
exit;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment