[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: manually_enter_result.php
<?php include("functions.php"); //error_reporting(0); if(!isset($_SESSION['dbmail_Xw211qAAsq4'])){ header("location:../auth-login"); } else { $s_code = $_SESSION['s_code_Xw2119904'] ?? ''; $uname = $_SESSION['name_Xw2119904'] ?? ''; $stmt = $con->prepare("Select * from schools where school_code = ?"); $stmt->execute(array($s_code)); $row = $stmt->fetch(); $logo = $row['logo']; if(empty($logo)){ header("Location:complete-process"); } else { if (isset($_POST['save_results'])) { $semester = test_input($_POST['semester']); $academic = test_input($_POST['academic']); // Use prepared statement for security $stmt = $new->prepare("INSERT INTO student_result (index_number,student_name,subject,class_score,exams_score,total_score,grading,remarks,s_code,form,term,academicyear, programme,r_status,teacher) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)"); if (!$stmt) { die("Prepare failed: " . $new->error); } foreach ($_POST['classname'] as $key => $classname) { $subject_name = test_input($_POST['subject_name'][$key]); $student_id = test_input($_POST['student_id'][$key]); $form = test_input($_POST['form'][$key]); $class_score = (float) $_POST['class_score'][$key]; $exam_score = (float) $_POST['exams_score'][$key]; $total_score = (float) $_POST['total_score'][$key]; $grade = test_input($_POST['grade'][$key]); $remark = test_input($_POST['remark'][$key]); $r_status = test_input($_POST['r_status'][$key]); $getname = $new->query("SELECT student_name,programe FROM enrol_details WHERE index_no = '$student_id' AND s_code = '$s_code'"); $getmyname = mysqli_fetch_array($getname); $myname = $getmyname['student_name']; $myprograme = $getmyname['programe']; $stmt->bind_param( "sssssssssssssss", $student_id, $myname, $subject_name, $class_score, $exam_score, $total_score, $grade, $remark, $s_code, $form, $semester, $academic, $myprograme, $r_status, $uname ); $stmt->execute(); } echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Success!', text: '✅ Student results saved successfully', icon: 'success', confirmButtonText: 'OK' }); }); </script>"; } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>ENTER STUDENT RESULT </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- App favicon --> <!-- DataTables --> <link href="assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <link href="assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- Responsive datatable examples --> <link href="assets/libs/datatables.net-responsive-bs4/css/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" /> <!-- preloader css --> <link rel="stylesheet" href="assets/css/preloader.min.css" type="text/css" /> <!-- Bootstrap Css --> <link href="assets/css/bootstrap.min.css" id="bootstrap-style" rel="stylesheet" type="text/css" /> <!-- Icons Css --> <link href="assets/css/icons.min.css" rel="stylesheet" type="text/css" /> <!-- App Css--> <link href="assets/css/app.min.css" id="app-style" rel="stylesheet" type="text/css" /> <link href="assets/libs/sweetalert2/sweetalert2.min.css" rel="stylesheet" type="text/css" /> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <!-- <body data-layout="horizontal"> --> <!-- Begin page --> <div id="layout-wrapper"> <?php include("includes/header.php");?> <?php include("includes/sidebar.php");?> <div class="main-content"> <div class="page-content"> <div class="container-fluid"> <!-- start page title --> <div class="row"> <div class="col-12"> <div class="page-title-box d-sm-flex align-items-center justify-content-between"> <h4 class="mb-sm-0 font-size-18">ENTER STUDENT RESULT</h4> <div class="page-title-right"> <ol class="breadcrumb m-0"> <li class="breadcrumb-item"><a href="javascript: void(0);">Home</a></li> <li class="breadcrumb-item active">ENTER STUDENT RESULT</li> </ol> </div> </div> </div> </div> <!-- end page title --> <div class="row"> <div class="col-12"> <?php // ✅ Fetch data from DB for dropdowns if ($uname != 'Admin') { $classes = $new->query("SELECT DISTINCT classname FROM teacher_subjects WHERE s_code = '$s_code' AND teacher_id = '$uname'"); } else { $classes = $new->query("SELECT DISTINCT classname FROM enrol_details WHERE s_code = '$s_code'"); } if ($uname != 'Admin') { $subject = $new->query("SELECT DISTINCT subject_name FROM teacher_subjects WHERE s_code = '$s_code' AND teacher_id = '$uname'"); } else { $subject = $new->query("SELECT DISTINCT subject_name FROM teacher_subjects WHERE s_code = '$s_code'"); } $forms = $new->query("SELECT DISTINCT student_form FROM enrol_details WHERE s_code = '$s_code'"); $mysem = $new->query("SELECT semester FROM semester WHERE s_code = '$s_code'"); ?> <form method="POST"> <div class="row"> <div class="col-4"> <div class="mb-4"> <label for="exampleInputEmail1" class="form-label">Semester</label> <select name="semester" class="form-select" required> <option value="">-- Select semester --</option> <?php while ($row = $mysem->fetch_assoc()): ?> <option value="<?= htmlspecialchars($row['semester']); ?>"> <?= htmlspecialchars($row['semester']); ?> </option> <?php endwhile; ?> </select> </div> </div> <div class="col-4"> <div class="mb-4"> <label for="exampleInputEmail1" class="form-label">Academic year</label> <select class="form-control" name="academic" required> <option value="">---ACADEMIC YEAR---</option> <option value="2024/2025" selected>2024/2025</option> <!-- <option value="2025/2026">2025/2026</option> <option value="2026/2027">2026/2027</option> <option value="2027/2028">2027/2028</option> <option value="2029/2030">2029/2030</option> --> </select> </div> </div> </div> <div class="row"> <div class="col-12"> <div class="table-responsive"> <table id="resultsTable" class="table table-striped align-middle"> <thead class="table-dark"> <tr> <th>#</th> <th>Select Class</th> <th>subject</th> <th>Student</th> <th>Form</th> <th>Class</th> <th>Exams</th> <th>Total</th> <th>Grade</th> <th>Remark</th> <th>Staus</th> <th>Action</th> </tr> </thead> <tbody id="resultsBody"> <tr> <td>1</td> <!-- CLASS --> <td> <select name="classname[]" class="form-select classSelect" required> <option value="">-- Select Class --</option> <?php while ($row = $classes->fetch_assoc()): ?> <option value="<?= htmlspecialchars($row['classname']); ?>"> <?= htmlspecialchars($row['classname']); ?> </option> <?php endwhile; ?> </select> </td> <td> <select name="subject_name[]" class="form-select" required> <option value="">-- Select Class --</option> <?php while ($row = $subject->fetch_assoc()): ?> <option value="<?= htmlspecialchars($row['subject_name']); ?>"> <?= htmlspecialchars($row['subject_name']); ?> </option> <?php endwhile; ?> </select> </td> <!-- STUDENT --> <td> <select name="student_id[]" class="form-select studentSelect" required> <option value="">-- Select --</option> </select> </td> <!-- FORM --> <td> <input type="text" class="form-control formDisplay" readonly> <input type="hidden" name="form[]" value=""> </td> <!-- SCORES --> <td><input type="number" name="class_score[]" class="form-control classScore" min="1" oninput="validateRange(this)" required></td> <td><input type="number" name="exams_score[]" class="form-control examScore" min="1" oninput="validateRangeExams(this)" required></td> <td><input type="number" name="total_score[]" class="form-control totalScore" readonly></td> <!-- GRADE --> <td><input type="text" name="grade[]" class="form-control gradeField" readonly></td> <!-- REMARK --> <td><input type="text" name="remark[]" class="form-control remarkField" readonly></td> <td> <select class="form-control" name="r_status[]" required> <option value="">Type</option> <option value="c">Core</option> <option value="e">Elective</option> </select> </td> <!-- REMOVE --> <td><button type="button" class="btn btn-danger removeRow">X</button></td> </tr> </tbody> </table> </div> <button type="button" id="addRow" class="btn btn-primary">Add Row</button> </div> </div> <div class="row mt-4"> <div class="col-12 text-center"> <button type="submit" name="save_results" class="btn btn-success">Submit</button> </div> </div> </form> <script> function validateRange(input) { if (input.value < 0) input.value = 0; if (input.value > 30) input.value = 30; } </script> <script> function validateRangeExams(input) { if (input.value < 0) input.value = 0; if (input.value > 70) input.value = 70; } </script> <script> async function loadStudents(selectElement) { const row = selectElement.closest("tr"); const classname = selectElement.value; const studentDropdown = row.querySelector(".studentSelect"); studentDropdown.innerHTML = `<option>Loading students...</option>`; if (classname) { try { const studentRes = await fetch(`student-fetch.php?classname=${encodeURIComponent(classname)}&s_code=<?= $s_code ?>`); const students = await studentRes.json(); studentDropdown.innerHTML = `<option value="">-- Select Student --</option>`; students.forEach(stu => { studentDropdown.innerHTML += `<option value="${stu.schoolID}" data-form="${stu.form}">${stu.student_name} (${stu.schoolID})</option>`; }); } catch (error) { studentDropdown.innerHTML = `<option>Error loading students</option>`; } } } // ✅ Event: Class change document.addEventListener("change", function (e) { if (e.target.classList.contains("classSelect")) { loadStudents(e.target); } }); // ✅ Event: Student selection (auto-fill form) document.addEventListener("change", function (e) { if (e.target.classList.contains("studentSelect")) { const selectedOption = e.target.options[e.target.selectedIndex]; const formValue = selectedOption.getAttribute("data-form"); const row = e.target.closest("tr"); const formDisplay = row.querySelector(".formDisplay"); const hiddenInput = row.querySelector("input[name='form[]']"); formDisplay.value = formValue || ""; hiddenInput.value = formValue || ""; } }); // ✅ Calculate total, grade & remark dynamically document.addEventListener("input", function (e) { if (e.target.classList.contains("classScore") || e.target.classList.contains("examScore")) { const row = e.target.closest("tr"); const classInput = row.querySelector(".classScore"); const examInput = row.querySelector(".examScore"); let classScore = parseFloat(classInput.value) || 0; let examScore = parseFloat(examInput.value) || 0; classScore = parseFloat(classInput.value) || 0; examScore = parseFloat(examInput.value) || 0; const total = classScore + examScore; row.querySelector(".totalScore").value = total; let grade = "", remark = ""; if (total >= 80) { grade = "A1"; remark = "EXCELLENT"; } else if (total >= 75) { grade = "B2"; remark = "VERY GOOD"; } else if (total >= 70) { grade = "B3"; remark = "GOOD"; } else if (total >= 65) { grade = "C4"; remark = "CREDIT"; } else if (total >= 60) { grade = "C5"; remark = "CREDIT"; } else if (total >= 55) { grade = "C6"; remark = "CREDIT"; } else if (total >= 45) { grade = "D7"; remark = "PASS"; } else if (total >= 40) { grade = "E8"; remark = "PASS"; } else { grade = "F9"; remark = "FAIL"; } row.querySelector(".gradeField").value = grade; row.querySelector(".remarkField").value = remark; } }); // ➕ Add Row document.getElementById("addRow").addEventListener("click", function () { const tbody = document.getElementById("resultsBody"); const newRow = tbody.rows[0].cloneNode(true); const rowCount = tbody.rows.length + 1; newRow.cells[0].innerText = rowCount; newRow.querySelectorAll("input").forEach(input => input.value = ""); newRow.querySelector(".studentSelect").innerHTML = `<option>-- Select --</option>`; newRow.querySelector(".formDisplay").value = ""; newRow.querySelector("input[name='form[]']").value = ""; tbody.appendChild(newRow); }); // ❌ Remove Row document.addEventListener("click", function (e) { if (e.target.classList.contains("removeRow")) { if (document.querySelectorAll("#resultsBody tr").length > 1) { e.target.closest("tr").remove(); } } }); </script> </div> </div> <!-- end col --> </div> <!-- end row --> </div> <!-- container-fluid --> </div> <!-- End Page-content --> <?php include("includes/footer.php");?> </div> <!-- end main content--> </div> <!-- END layout-wrapper --> <!-- Right Sidebar --> <div class="right-bar"> <div data-simplebar class="h-100"> <div class="rightbar-title d-flex align-items-center p-3"> <h5 class="m-0 me-2">Theme Customizer</h5> <a href="javascript:void(0);" class="right-bar-toggle ms-auto"> <i class="mdi mdi-close noti-icon"></i> </a> </div> <!-- Settings --> <hr class="m-0" /> <div class="p-4"> <h6 class="mb-3">Layout</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout" id="layout-vertical" value="vertical"> <label class="form-check-label" for="layout-vertical">Vertical</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout" id="layout-horizontal" value="horizontal"> <label class="form-check-label" for="layout-horizontal">Horizontal</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Mode</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-mode" id="layout-mode-light" value="light"> <label class="form-check-label" for="layout-mode-light">Light</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-mode" id="layout-mode-dark" value="dark"> <label class="form-check-label" for="layout-mode-dark">Dark</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Width</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-width" id="layout-width-fuild" value="fuild" onchange="document.body.setAttribute('data-layout-size', 'fluid')"> <label class="form-check-label" for="layout-width-fuild">Fluid</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-width" id="layout-width-boxed" value="boxed" onchange="document.body.setAttribute('data-layout-size', 'boxed')"> <label class="form-check-label" for="layout-width-boxed">Boxed</label> </div> <h6 class="mt-4 mb-3 pt-2">Layout Position</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-position" id="layout-position-fixed" value="fixed" onchange="document.body.setAttribute('data-layout-scrollable', 'false')"> <label class="form-check-label" for="layout-position-fixed">Fixed</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-position" id="layout-position-scrollable" value="scrollable" onchange="document.body.setAttribute('data-layout-scrollable', 'true')"> <label class="form-check-label" for="layout-position-scrollable">Scrollable</label> </div> <h6 class="mt-4 mb-3 pt-2">Topbar Color</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="topbar-color" id="topbar-color-light" value="light" onchange="document.body.setAttribute('data-topbar', 'light')"> <label class="form-check-label" for="topbar-color-light">Light</label> </div> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="topbar-color" id="topbar-color-dark" value="dark" onchange="document.body.setAttribute('data-topbar', 'dark')"> <label class="form-check-label" for="topbar-color-dark">Dark</label> </div> <h6 class="mt-4 mb-3 pt-2 sidebar-setting">Sidebar Size</h6> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-default" value="default" onchange="document.body.setAttribute('data-sidebar-size', 'lg')"> <label class="form-check-label" for="sidebar-size-default">Default</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-compact" value="compact" onchange="document.body.setAttribute('data-sidebar-size', 'md')"> <label class="form-check-label" for="sidebar-size-compact">Compact</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-size" id="sidebar-size-small" value="small" onchange="document.body.setAttribute('data-sidebar-size', 'sm')"> <label class="form-check-label" for="sidebar-size-small">Small (Icon View)</label> </div> <h6 class="mt-4 mb-3 pt-2 sidebar-setting">Sidebar Color</h6> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-light" value="light" onchange="document.body.setAttribute('data-sidebar', 'light')"> <label class="form-check-label" for="sidebar-color-light">Light</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-dark" value="dark" onchange="document.body.setAttribute('data-sidebar', 'dark')"> <label class="form-check-label" for="sidebar-color-dark">Dark</label> </div> <div class="form-check sidebar-setting"> <input class="form-check-input" type="radio" name="sidebar-color" id="sidebar-color-brand" value="brand" onchange="document.body.setAttribute('data-sidebar', 'brand')"> <label class="form-check-label" for="sidebar-color-brand">Brand</label> </div> <h6 class="mt-4 mb-3 pt-2">Direction</h6> <div class="form-check form-check-inline"> <input class="form-check-input" type="radio" name="layout-direction" id="layout-direction-ltr" value="ltr"> <label class="form-check-label" for="layout-direction-ltr">LTR</label> </div> </div> </div> <!-- end slimscroll-menu--> </div> <!-- /Right-bar --> <!-- Right bar overlay--> <div class="rightbar-overlay"></div> <!-- JAVASCRIPT --> <script src="assets/libs/jquery/jquery.min.js"></script> <script src="assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> <script src="assets/libs/metismenu/metisMenu.min.js"></script> <script src="assets/libs/simplebar/simplebar.min.js"></script> <script src="assets/libs/node-waves/waves.min.js"></script> <script src="assets/libs/feather-icons/feather.min.js"></script> <!-- pace js --> <script src="assets/libs/pace-js/pace.min.js"></script> <!-- Required datatable js --> <script src="assets/libs/datatables.net/js/jquery.dataTables.min.js"></script> <script src="assets/libs/datatables.net-bs4/js/dataTables.bootstrap4.min.js"></script> <!-- Buttons examples --> <script src="assets/libs/datatables.net-buttons/js/dataTables.buttons.min.js"></script> <script src="assets/libs/datatables.net-buttons-bs4/js/buttons.bootstrap4.min.js"></script> <script src="assets/libs/jszip/jszip.min.js"></script> <script src="assets/libs/pdfmake/build/pdfmake.min.js"></script> <script src="assets/libs/pdfmake/build/vfs_fonts.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.html5.min.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.print.min.js"></script> <script src="assets/libs/datatables.net-buttons/js/buttons.colVis.min.js"></script> <!-- Responsive examples --> <script src="assets/libs/datatables.net-responsive/js/dataTables.responsive.min.js"></script> <script src="assets/libs/datatables.net-responsive-bs4/js/responsive.bootstrap4.min.js"></script> <script src="assets/libs/sweetalert2/sweetalert2.min.js"></script> <!-- Datatable init js --> <script src="assets/js/pages/datatables.init.js"></script> <script src="assets/js/app.js"></script> <script src="assets/js/pages/validation.init.js"></script> <script src="assets/js/pages/modal.init.js"></script> <script> var myModal = document.getElementById('myModal') var myInput = document.getElementById('myInput') myModal.addEventListener('shown.bs.modal', function () { myInput.focus() }) </script> </body> </html>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.81 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002