diff --git a/Presentation/LoginPage.php b/Presentation/LoginPage.php index 6af1d0a950dfff693b3950278108a352adf0b5f1..cab7139ff06df3c83ed9e560c99f23e02906b1c4 100644 --- a/Presentation/LoginPage.php +++ b/Presentation/LoginPage.php @@ -1,13 +1,13 @@ <?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>"; } diff --git a/Presentation/chatPage.php b/Presentation/chatPage.php index 8b4b095dea9ccbf86e5b831ed57e7ad9320e0da3..a615222ad0af194bd4726780c4b30d90da134e36 100644 --- a/Presentation/chatPage.php +++ b/Presentation/chatPage.php @@ -11,7 +11,7 @@ <body> <!-- 在线用户列表容器 --> <div id="sidebar"> - <h2>在线用户:</h2> + <h2>Online Users:</h2> <ul id="online-users-list"> <!-- 在线用户将在这里列出 --> </ul> diff --git a/Presentation/register.php b/Presentation/register.php index 35afeb37cb3188ceb082c308263eed88d755f0b7..fec8471c8968fb36f253c478c2bf8225f8b0d28f 100644 --- a/Presentation/register.php +++ b/Presentation/register.php @@ -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; }