??????????????
??????????????
alert('Certificate deleted successfully!'); window.location='';";
}
// Insert record
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$target_dir = "uploads/";
if (!is_dir($target_dir)) mkdir($target_dir);
$cert_image_path = "";
// Certificate Image upload
if (!empty($_FILES["certificate_image"]["name"])) {
$cert_image_path = $target_dir . time() . '_cert_' . basename($_FILES["certificate_image"]["name"]);
if (!move_uploaded_file($_FILES["certificate_image"]["tmp_name"], $cert_image_path)) {
echo "";
$cert_image_path = ""; // Clear path on failure
}
}
// Student Photo upload
$student_photo_path = "";
if (!empty($_FILES["student_photo"]["name"])) {
$student_photo_path = $target_dir . time() . '_student_' . basename($_FILES["student_photo"]["name"]);
if (!move_uploaded_file($_FILES["student_photo"]["tmp_name"], $student_photo_path)) {
echo "";
$student_photo_path = ""; // Clear path on failure
}
}
// Use prepared statements to prevent SQL injection
$sql = "INSERT INTO certificates (student_name, father_name, registration_no, certificate_no, course_name, session, duration, grade, exam_held, issue_date, certificate_image, student_photo)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
if ($stmt = mysqli_prepare($conn, $sql)) {
mysqli_stmt_bind_param($stmt, "ssssssssssss",
$_POST['student_name'], $_POST['father_name'], $_POST['registration_no'], $_POST['certificate_no'],
$_POST['course_name'], $_POST['session'], $_POST['duration'], $_POST['grade'],
$_POST['exam_held'], $_POST['issue_date'], $cert_image_path, $student_photo_path
);
mysqli_stmt_execute($stmt);
mysqli_stmt_close($stmt);
echo "";
} else {
echo "";
}
}
$result = mysqli_query($conn, "SELECT * FROM certificates ORDER BY id DESC");
?>
Fee Report |Xcel Training Institute