+
+
diff --git a/BT/Tuan 3/Bai 2/upload/hinh-nen-luffy-gear-5-58.jpg b/BT/Tuan 3/Bai 2/upload/hinh-nen-luffy-gear-5-58.jpg
new file mode 100644
index 000000000..4bcbc52d6
Binary files /dev/null and b/BT/Tuan 3/Bai 2/upload/hinh-nen-luffy-gear-5-58.jpg differ
diff --git a/BT/Tuan 3/Bai 2/upload/hinh-nen-luffy-gear-5-59.jpg b/BT/Tuan 3/Bai 2/upload/hinh-nen-luffy-gear-5-59.jpg
new file mode 100644
index 000000000..d0ed2a5b2
Binary files /dev/null and b/BT/Tuan 3/Bai 2/upload/hinh-nen-luffy-gear-5-59.jpg differ
diff --git a/BT/Tuan 3/Bai 3/BT3-W3.sql b/BT/Tuan 3/Bai 3/BT3-W3.sql
new file mode 100644
index 000000000..e69de29bb
diff --git a/BT/Tuan 3/Bai 3/db_config.php b/BT/Tuan 3/Bai 3/db_config.php
new file mode 100644
index 000000000..e69de29bb
diff --git a/BT/Tuan 3/Bai 3/index.php b/BT/Tuan 3/Bai 3/index.php
new file mode 100644
index 000000000..e69de29bb
diff --git a/BT/Tuan 3/Bai 3/register.php b/BT/Tuan 3/Bai 3/register.php
new file mode 100644
index 000000000..992912905
--- /dev/null
+++ b/BT/Tuan 3/Bai 3/register.php
@@ -0,0 +1,72 @@
+ 0) {
+ $error = "Tên đăng nhập đã tồn tại.";
+ } else {
+ // Mã hóa mật khẩu bằng SHA1
+ $hashed_password = sha1($password);
+
+ // Lưu thông tin người dùng vào CSDL
+ $sql = "INSERT INTO users (username, password, email) VALUES ('$username', '$hashed_password', '$email')";
+ mysqli_query($conn, $sql);
+
+ if (mysqli_affected_rows($conn) > 0) {
+ $success = "Đăng ký thành công!";
+ } else {
+ $error = "Lỗi khi đăng ký.";
+ }
+ }
+ }
+}
+
+?>
+
+
+
+
+
+
+ Đăng ký
+
+
+
+
Đăng ký
+
+ $error"; ?>
+ $success"; ?>
+
+
+
+
\ No newline at end of file
diff --git a/BT/Tuan 3/Bai 3/style.css b/BT/Tuan 3/Bai 3/style.css
new file mode 100644
index 000000000..e69de29bb
diff --git a/BT/Tuan 3/Bai 3/upload.php b/BT/Tuan 3/Bai 3/upload.php
new file mode 100644
index 000000000..e69de29bb
diff --git a/BT/Tuan 3/Bai 3/upload/hinh-nen-luffy-gear-5-58.jpg b/BT/Tuan 3/Bai 3/upload/hinh-nen-luffy-gear-5-58.jpg
new file mode 100644
index 000000000..4bcbc52d6
Binary files /dev/null and b/BT/Tuan 3/Bai 3/upload/hinh-nen-luffy-gear-5-58.jpg differ
diff --git a/BT/Tuan 3/Bai 3/upload/hinh-nen-luffy-gear-5-59.jpg b/BT/Tuan 3/Bai 3/upload/hinh-nen-luffy-gear-5-59.jpg
new file mode 100644
index 000000000..d0ed2a5b2
Binary files /dev/null and b/BT/Tuan 3/Bai 3/upload/hinh-nen-luffy-gear-5-59.jpg differ
diff --git a/BT/Tuan 3/Bai 4/BT4-W3.sql b/BT/Tuan 3/Bai 4/BT4-W3.sql
new file mode 100644
index 000000000..b973c1fea
--- /dev/null
+++ b/BT/Tuan 3/Bai 4/BT4-W3.sql
@@ -0,0 +1,7 @@
+CREATE TABLE files (
+ id INT PRIMARY KEY AUTO_INCREMENT,
+ name VARCHAR(255) NOT NULL,
+ type VARCHAR(50) NOT NULL,
+ size BIGINT NOT NULL,
+ uploaded_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
diff --git a/BT/Tuan 3/Bai 4/db_config.php b/BT/Tuan 3/Bai 4/db_config.php
new file mode 100644
index 000000000..2361b2620
--- /dev/null
+++ b/BT/Tuan 3/Bai 4/db_config.php
@@ -0,0 +1,13 @@
+
diff --git a/BT/Tuan 3/Bai 4/index.php b/BT/Tuan 3/Bai 4/index.php
new file mode 100644
index 000000000..ad3e1f11d
--- /dev/null
+++ b/BT/Tuan 3/Bai 4/index.php
@@ -0,0 +1,83 @@
+ 2097152) { // 2MB
+ $error = "Kích thước tệp tin vượt quá giới hạn (2MB).";
+ }
+
+ // Kiểm tra loại tệp tin hợp lệ
+ $allow_types = array('jpg', 'jpeg', 'png', 'gif', 'pdf', 'doc', 'docx', 'xls', 'xlsx');
+ if (!in_array($file_type, $allow_types)) {
+ $error = "Chỉ hỗ trợ các loại tệp tin: " . implode(', ', $allow_types) . ".";
+ }
+
+ // Nếu không có lỗi, tiến hành tải lên tệp tin
+ if (!$error) {
+ // Tạo tên tệp tin mới theo định dạng: YYYYMMDD_HHMMSS_Mã_ngẫu_nhiên.ext
+ $new_file_name = date('YmdHis') . '_' . uniqid() . '.' . $file_type;
+ $target_file = $target_dir . $new_file_name;
+
+ // Di chuyển tệp tin từ vị trí tạm thời vào thư mục đích
+ if (move_uploaded_file($temp_file, $target_file)) {
+ // Lưu thông tin tệp tin vào CSDL
+ $sql = "INSERT INTO files (name, type, size, uploaded_at) VALUES ('$new_file_name', '$file_type', '" . $_FILES['myfile']['size'] . "', NOW())";
+ mysqli_query($conn, $sql);
+
+ if (mysqli_affected_rows($conn) > 0) {
+ $success = "Tải lên tệp tin thành công!";
+ } else {
+ $error = "Lỗi khi lưu thông tin tệp tin.";
+ }
+ } else {
+ $error = "Lỗi khi di chuyển tệp tin.";
+ }
+ }
+}
+
+// Lấy danh sách tệp tin từ CSDL
+$sql = "SELECT * FROM files ORDER BY name ASC"; // Sắp xếp theo tên tệp tin (tăng dần)
+if (isset($_GET['sort']) && $_GET['sort'] == 'date') {
+ $sql = "SELECT * FROM files ORDER BY uploaded_at DESC"; // Sắp xếp theo ngày tải lên (giảm dần)
+}
+$result = mysqli_query($conn, $sql);
+
+?>
+
+
+
+
+
+
+ Quản lý tệp tin
+
+
+
+
Quản lý tệp tin
+
+ $error"; ?>
+ $success"; ?>
+
+
Tải lên tệp tin
+
+
+
Danh sách tệp tin
+
+
+
+
Tên tệp tin
diff --git a/BT/Tuan 3/Bai 4/style.css b/BT/Tuan 3/Bai 4/style.css
new file mode 100644
index 000000000..ccb67c5e8
--- /dev/null
+++ b/BT/Tuan 3/Bai 4/style.css
@@ -0,0 +1,53 @@
+body {
+ font-family: Arial, sans-serif;
+ margin: 0;
+ padding: 20px;
+}
+
+h1 {
+ text-align: center;
+ margin-bottom: 20px;
+}
+
+form {
+ width: 300px;
+ margin: 0 auto;
+ padding: 20px;
+ border: 1px solid #ccc;
+}
+
+form label {
+ display: block;
+ margin-bottom: 5px;
+}
+
+form input[type="file"] {
+ width: 100%;
+ padding: 8px;
+ border: 1px solid #ccc;
+ box-sizing: border-box;
+}
+
+form button {
+ padding: 8px 15px;
+ background-color: #4CAF50;
+ color: white;
+ border: none;
+ cursor: pointer;
+}
+
+table {
+ width: 100%;
+ margin-top: 20px;
+ border-collapse: collapse;
+}
+
+th, td {
+ border: 1px solid #ccc;
+ padding: 8px;
+ text-align: left;
+}
+
+th {
+ background-color: #f2f2f2;
+}
diff --git a/BT/Tuan 3/Bai 4/upload.php b/BT/Tuan 3/Bai 4/upload.php
new file mode 100644
index 000000000..2268fcad4
--- /dev/null
+++ b/BT/Tuan 3/Bai 4/upload.php
@@ -0,0 +1,52 @@
+ 0) {
+ $row = mysqli_fetch_assoc($result);
+
+ // Xóa tệp tin khỏi ổ cứng
+ $target_file = "upload/" . $row['name'];
+ unlink($target_file);
+
+ // Xóa thông tin tệp tin khỏi CSDL
+ $sql = "DELETE FROM files WHERE id = $file_id";
+ mysqli_query($conn, $sql);
+
+ if (mysqli_affected_rows($conn) > 0) {
+ $success = "Xóa tệp tin thành công!";
+ header('Location: index.php'); // Trở về trang chủ sau khi xóa
+ exit();
+ } else {
+ $error = "Lỗi khi xóa thông tin tệp tin.";
+ }
+ } else {
+ $error = "Tệp tin không tồn tại.";
+ }
+}
+
+// Lấy danh sách tệp tin từ CSDL (phần này có thể di chuyển vào index.php)
+$sql = "SELECT * FROM files ORDER BY name ASC"; // Sắp xếp theo tên tệp tin (tăng dần)
+if (isset($_GET['sort']) && $_GET['sort'] == 'date') {
+ $sql = "SELECT * FROM files ORDER BY uploaded_at DESC"; // Sắp xếp theo ngày tải lên (giảm dần)
+}
+$result = mysqli_query($conn, $sql);
+?>
+
+**4. File `delete.php`** (trong thư mục `includes`):**
+
+```php
+
+
+
+
+
+ Đăng nhập
+
+
+
+
+
Đăng nhập
+
+
+
+
diff --git a/BT/Tuan 3/Bai1/logout.php b/BT/Tuan 3/Bai1/logout.php
new file mode 100644
index 000000000..d3315d8ed
--- /dev/null
+++ b/BT/Tuan 3/Bai1/logout.php
@@ -0,0 +1,16 @@
+
diff --git a/BT/Tuan 3/Bai1/protect.php b/BT/Tuan 3/Bai1/protect.php
new file mode 100644
index 000000000..6e92e2013
--- /dev/null
+++ b/BT/Tuan 3/Bai1/protect.php
@@ -0,0 +1,25 @@
+';
+
+// Xử lý form
+if (isset($_POST["token"]) && $_POST["token"] === $token) {
+ // Xử lý form an toàn
+} else {
+ // Lỗi mã token CSRF
+ echo "Mã token CSRF không hợp lệ!";
+}
diff --git a/BT/Tuan 3/Bai1/validateuser.php b/BT/Tuan 3/Bai1/validateuser.php
new file mode 100644
index 000000000..01661140d
--- /dev/null
+++ b/BT/Tuan 3/Bai1/validateuser.php
@@ -0,0 +1,41 @@
+ 0) {
+ // Đăng nhập thành công
+ $_SESSION["IsLogin"] = true; // Lưu trạng thái đăng nhập
+ header("Location: welcome.php"); // Chuyển hướng đến trang chào mừng
+ exit();
+} else {
+ // Đăng nhập thất bại
+ echo "Tên người dùng hoặc mật khẩu không hợp lệ!";
+ header("Location: login.html"); // Chuyển hướng về trang login
+}
+
+// Đóng kết nối CSDL
+mysqli_close($conn);
\ No newline at end of file
diff --git a/BT/Tuan 3/Bai1/welcome.php b/BT/Tuan 3/Bai1/welcome.php
new file mode 100644
index 000000000..a2318700a
--- /dev/null
+++ b/BT/Tuan 3/Bai1/welcome.php
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Trang chủ
+
+
+
Trang chủ
+
+
Chào mừng bạn đến với trang web của chúng tôi!
+
+
+
+
+
diff --git a/README.md b/README.md
index 6eaa82ecb..3779ab5d6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,9 @@
-# Try Out Development Containers: PHP
+# Development Containers: PHP
+Nhóm:
+
+1. Dang Hoang Anh
+2. Nguyen Xuan Hieu
+3. Nguyen Le Thu
[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/vscode-remote-try-php)