Quản trị Thông tin người Người hành nghề KBCB
set_charset("utf8");
if ($_FILES['excel_file']['error'] === 0) {
try {
$filePath = $_FILES['excel_file']['tmp_name'];
$spreadsheet = IOFactory::load($filePath);
$sheet = $spreadsheet->getActiveSheet()->toArray();
$conn->query("TRUNCATE TABLE nguoi_hanh_nghe");
foreach ($sheet as $i => $row) {
if ($i === 0 || empty($row[0])) continue;
$stmt = $conn->prepare("INSERT INTO nguoi_hanh_nghe (ho_ten, so_cchn, pham_vi_hoat_dong, thoi_gian_hanh_nghe, vi_tri_chuyen_mon, don_vi) VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssss", $row[0], $row[1], $row[2], $row[3], $row[4], $row[5]);
$stmt->execute();
}
header("Location: upload_excel_with_alert.html?success=1");
exit();
} catch (Exception $e) {
header("Location: upload_excel_with_alert.html?error=1");
exit();
}
} else {
header("Location: upload_excel_with_alert.html?error=1");
exit();
}
?>
