Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a4371db
Model-View-Controller Update
KhuatKien Apr 15, 2024
464352d
change text
anhhducnguyen Apr 15, 2024
6303cd5
TimSach System
KhuatKien Apr 16, 2024
634f3b8
code system 'TimSach'
KhuatKien Apr 19, 2024
5a33020
update index php
BimTD Apr 19, 2024
8f7a97e
Xuất dữ liệu ra trình duyệt
KhuatKien Apr 19, 2024
fc58119
Khai báo hằng
KhuatKien Apr 19, 2024
4d1b90b
Kiểu dữ liệu - mô tả
KhuatKien Apr 19, 2024
03cf996
Chuyển kiểu dữ liệu
KhuatKien Apr 19, 2024
e7093e0
Tham chiếu trong PHP
KhuatKien Apr 19, 2024
5a3ab4d
Bài tập
KhuatKien Apr 19, 2024
3eed143
Bài tập
KhuatKien Apr 19, 2024
2f329d0
Bài tập
KhuatKien Apr 19, 2024
822e1f5
Bài tập
KhuatKien Apr 19, 2024
b323c38
BaiTapLogin-Slide125
KhuatKien Apr 19, 2024
205587e
Merge branch 'KhuatKien'
KhuatKien Apr 19, 2024
f1cc21d
conect db
KhuatKien Apr 24, 2024
8689e18
Create project
KhuatKien Apr 25, 2024
af73990
db img
KhuatKien Apr 26, 2024
c04fb72
merge-bt_login
BimTD May 6, 2024
4a93ac4
Bai3+4
KhuatKien May 6, 2024
ef1622a
Bai3+4: Upload file
KhuatKien May 6, 2024
cf24a81
Merge branch 'main' of https://github.com/KhuatKien/WebNangCao-Nhom15
KhuatKien May 6, 2024
0a4c56c
xóa file thừa
KhuatKien May 6, 2024
70e7080
remname folder
KhuatKien May 6, 2024
4b6866c
update_color_uploadFile
BimTD May 6, 2024
2f01866
.
KhuatKien May 6, 2024
5153c0a
.
KhuatKien May 6, 2024
8af82e6
.
KhuatKien May 6, 2024
5e692f6
.
KhuatKien May 6, 2024
213e0a5
.
BimTD May 6, 2024
58c1298
.
BimTD May 6, 2024
6e62c38
update
BimTD May 6, 2024
c3d4f88
Bài tập thực hành PHP-Security
BimTD May 24, 2024
a8a88a4
Bài tập giữa kỳ - Bài 2
KhuatKien May 24, 2024
2a846b8
Update README.md
nglthu May 30, 2024
5fe890e
Update README.md
nglthu May 30, 2024
f074c4d
Update SSO
BimTD Jun 7, 2024
4c1514a
up project
KhuatKien Jun 12, 2024
d43ec18
.
KhuatKien Jun 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions BT_Login/home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
session_start();
if(isset($_SESSION['username']) && ($_SESSION['username']!=""))
{
$username = $_SESSION['username'];
}
if(isset($_SESSION['password']) && ($_SESSION['password']!=""))
{
$password = $_SESSION['password'];
}
if($username!="") $logined="Xin chào: ".$username;
else $logined="Login";
if($password!="") $passworded="Mật khẩu: ".$password;
else $passworded="...";
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<title>Logout</title>
</head>

<body>
<p style="margin: 20px;"><?=$logined?></p>
<p style="margin: 20px;"><?=$passworded?></p>
<p style="margin: 20px;">
<a href="logout.php" class="btn btn-info btn-lg">
<span class="glyphicon glyphicon-log-out"></span> Thoát
</a>
</p>
</body>
</html>
43 changes: 43 additions & 0 deletions BT_Login/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<title>Login</title>
</head>
<body>
<div id="login">
<h3 class="text-center text-white pt-5">Login form</h3>
<div class="container">
<div id="login-row" class="row justify-content-center align-items-center">
<div id="login-column" class="col-md-6">
<div id="login-box" class="col-md-12">
<form id="login-form" class="form" action="validateuser.php" method="post">
<h3 class="text-center text-info">Đăng nhập</h3>
<div class="form-group">
<label for="username" class="text-info">Tài khoản:</label><br>
<input type="text" name="username" id="username" class="form-control">
</div>
<div class="form-group">
<label for="password" class="text-info">Mật khẩu:</label><br>
<input type="password" name="password" id="password" class="form-control">
</div>
<div class="form-group">
<label for="remember-me" class="text-info"><span>Ghi nhớ</span> <span><input id="remember-me" name="remember-me" type="checkbox"></span></label><br>
<input type="submit" name="login_submit" class="btn btn-info btn-md" value="Đăng nhập">
</div>
<div id="register-link" class="text-right">
<a href="signin.php" class="text-info">Đăng ký</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
42 changes: 42 additions & 0 deletions BT_Login/registeruser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
$host = "localhost";
$user = "root";
$password = "123456789";
$con = mysqli_connect($host, $user, $password);

mysqli_select_db($con, "login");
session_start();

if (!isset($_SESSION["IsLogin"])) {
$_SESSION["IsLogin"] = false;
}

if(isset($_POST['register_submit'])) {
$new_username = $_POST['new-username'];
$new_password = $_POST['new-password'];
$confirm_password = $_POST['confirm-password'];

// Kiểm tra xem mật khẩu và xác nhận mật khẩu có khớp nhau không
if($new_password != $confirm_password) {
echo "<script>alert('Mật khẩu và xác nhận mật khẩu không khớp!'); window.location.href = 'register.php';</script>";
exit(); // Thoát khỏi script nếu mật khẩu không khớp
}

// Kiểm tra xem tên người dùng đã tồn tại chưa
$check_query = "SELECT * FROM tbllogin WHERE username='$new_username'";
$check_result = mysqli_query($con, $check_query);

if(mysqli_num_rows($check_result) > 0) {
echo "<script>alert('Tên đăng nhập đã tồn tại!'); window.location.href = 'register.php';</script>";
exit(); // Thoát khỏi script nếu tên đăng nhập đã tồn tại
}

$hashed_password = sha1($new_password);

// Nếu không có vấn đề gì, thực hiện thêm người dùng vào cơ sở dữ liệu
$insert_query = "INSERT INTO tbllogin (username, password) VALUES ('$new_username', '$hashed_password')";
mysqli_query($con, $insert_query);

echo "<script>alert('Đăng ký thành công!'); window.location.href = 'login.php';</script>";
}
?>
46 changes: 46 additions & 0 deletions BT_Login/signin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<title>Register</title>
</head>
<body>
<div id="register">
<h3 class="text-center text-white pt-5">Register form</h3>
<div class="container">
<div id="register-row" class="row justify-content-center align-items-center">
<div id="register-column" class="col-md-6">
<div id="register-box" class="col-md-12">
<form id="register-form" class="form" action="registeruser.php" method="post">
<h3 class="text-center text-info">Đăng ký</h3>
<div class="form-group">
<label for="new-username" class="text-info">Tài khoản:</label><br>
<input type="text" name="new-username" id="new-username" class="form-control">
</div>
<div class="form-group">
<label for="new-password" class="text-info">Mật khẩu:</label><br>
<input type="password" name="new-password" id="new-password" class="form-control">
</div>
<div class="form-group">
<label for="confirm-password" class="text-info">Xác nhận mật khẩu:</label><br>
<input type="password" name="confirm-password" id="confirm-password" class="form-control">
</div>
<div class="form-group">
<input type="submit" name="register_submit" class="btn btn-info btn-md" value="Đăng ký">
</div>
<div id="login-link" class="text-right">
<a href="login.php" class="text-info">Đăng nhập</a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
41 changes: 41 additions & 0 deletions BT_Login/validateuser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
$host = "localhost";
$user = "root";
$password = "123456789";
$con = mysqli_connect($host, $user, $password);

mysqli_select_db($con, "login");
session_start();

if (!isset($_SESSION["IsLogin"])) {
$_SESSION["IsLogin"] = false;
}
// Kiểm tra xem nút Đăng nhập đã được bấm chưa
if(isset($_POST['login_submit'])) {
// Lấy dữ liệu từ form
$username = $_POST['username'];
$password = $_POST['password'];

$check_password = sha1($password);
echo $check_password;
$query = "SELECT * FROM tbllogin WHERE username='$username' AND password='$check_password'";
$result = mysqli_query($con, $query);

// Kiểm tra kết quả trả về
if(mysqli_num_rows($result) == 1) {
// $content="/BT_login/logout.php";
// echo ("<script>location.href='$content'</script>");
$_SESSION["IsLogin"] = true;
$_SESSION['username'] = $username;
$_SESSION['password'] = $password;

// $update_query = "UPDATE tbllogin SET password='$hashed_password' WHERE username='$username'";
// mysqli_query($con, $update_query);
header("Location: home.php");
} else {
echo "<script>alert('Tên đăng nhập hoặc mật khẩu không đúng!'); window.location.href = 'login.php';</script>";
}
}


?>
61 changes: 61 additions & 0 deletions BT_QuanLySinhVien/sinhvien.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sinh Viên</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}

th,
td {
border: 1px solid black;
padding: 8px;
text-align: left;
}
</style>
</head>

<body>
<h3>Danh sách sinh viên đăng ký môn học</h3>
<table>
<thead>
<tr>
<th>MSSV</th>
<th>Họ và tên</th>
<th>Môn học</th>
<th>Kỳ học</th>
</tr>
</thead>
<tbody>
<?php
$host = "localhost";
$user = "root";
$password = "123456";
$con = mysqli_connect($host, $user, $password);

mysqli_select_db($con, "sinhvien");
session_start();
$query = mysqli_query($con, "SELECT sv.MSSV, sv.HoTen, mh.TenMH, dk.Ky
FROM tblsinhvien AS sv
JOIN tbldangky AS dk ON sv.MSSV = dk.MSSV
JOIN tblmonhoc AS mh ON mh.MaMH = dk.MaMH;");
while ($row = mysqli_fetch_array($query)) {
echo "<tr>";
echo "<td>".$row['MSSV']."</td>";
echo "<td>".$row['HoTen']."</td>";
echo "<td>".$row['TenMH']."</td>";
echo "<td>".$row['Ky']."</td>";
echo "</tr>";
}
mysqli_close($con);
?>
</tbody>
</table>
</body>

</html>
Loading