Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NISH_code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
z54-chen
NISH_code
Commits
ae575867
Commit
ae575867
authored
1 year ago
by
CXM
Browse files
Options
Downloads
Patches
Plain Diff
Change some Chinese into English.
parent
75e72784
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Presentation/LoginPage.php
+15
-15
15 additions, 15 deletions
Presentation/LoginPage.php
Presentation/chatPage.php
+1
-1
1 addition, 1 deletion
Presentation/chatPage.php
Presentation/register.php
+3
-3
3 additions, 3 deletions
Presentation/register.php
with
19 additions
and
19 deletions
Presentation/LoginPage.php
+
15
−
15
View file @
ae575867
<?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>"
;
}
...
...
This diff is collapsed.
Click to expand it.
Presentation/chatPage.php
+
1
−
1
View file @
ae575867
...
...
@@ -11,7 +11,7 @@
<body>
<!-- 在线用户列表容器 -->
<div
id=
"sidebar"
>
<h2>
在线用户
:
</h2>
<h2>
Online Users
:
</h2>
<ul
id=
"online-users-list"
>
<!-- 在线用户将在这里列出 -->
</ul>
...
...
This diff is collapsed.
Click to expand it.
Presentation/register.php
+
3
−
3
View file @
ae575867
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment