-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacceptAllTasksTeacher.php
35 lines (28 loc) · 1.03 KB
/
acceptAllTasksTeacher.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
session_start();
require_once('koneksi.php');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$comment = $_POST['comment'];
$month = $_POST['month'];
// Validasi input
if (empty($name) || empty($month)) {
echo json_encode(['success' => false, 'error' => 'Wah, datanya belum lengkap nih']);
exit;
}
// Update semua tugas untuk siswa tertentu di bulan tertentu
$sql = "UPDATE laporan
SET status_g = 1, comment_g = ?
WHERE nama = ? AND DATE_FORMAT(waktu, '%Y-%m') = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sss", $comment, $name, $month);
if ($stmt->execute()) {
echo json_encode(['success' => true, 'message' => 'Sip, semua tugas udah diterima']);
} else {
echo json_encode(['success' => false, 'error' => 'Waduh, gagal update tugas: ' . $conn->error]);
}
$stmt->close();
} else {
echo json_encode(['success' => false, 'error' => 'Metode request-nya salah nih']);
}
$conn->close();