[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: submit_result.php
<?php require 'vendor/autoload.php'; // Autoload PHPSpreadsheet use PhpOffice\PhpSpreadsheet\IOFactory; include("../functions.php"); //error_reporting(0); if(!isset($_SESSION['dbmail_Xw211qAAsq4'])){ header("location:../auth-login"); } else { $s_code = $_SESSION['s_code_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["upload"])) { $term = isset($_POST['term']) ? test_input($_POST['term']) : ''; $academic = isset($_POST['academic']) ? test_input($_POST['academic']) : ''; $programme = isset($_POST['programme']) ? test_input($_POST['programme']) : ''; $file = $_FILES["file"]; $fileName = $file["tmp_name"]; $fileType = $file["type"]; $originalFileName = $file["name"]; // Check if the uploaded file is an Excel file $fileExtension = strtolower(pathinfo($originalFileName, PATHINFO_EXTENSION)); if (!in_array($fileExtension, ['xlsx', 'xls'])) { echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Error!', text: 'Please upload only Excel files (.xlsx or .xls).', icon: 'error', confirmButtonText: 'OK' }); }); </script>"; exit; } // Load the Excel file using PHPSpreadsheet try { $spreadsheet = IOFactory::load($fileName); $worksheet = $spreadsheet->getActiveSheet(); $rows = $worksheet->toArray(); // Skip the header row if it exists (adjust if no header) $isFirstRow = true; foreach ($rows as $column) { if ($isFirstRow) { $isFirstRow = false; continue; // Skip header row } // Extract data from each row $index_number = isset($column[0]) ? mysqli_real_escape_string($new, $column[0]) : ""; $subject = isset($column[1]) ? mysqli_real_escape_string($new, $column[1]) : ""; $class_score = isset($column[2]) ? mysqli_real_escape_string($new, $column[2]) : ""; $exams_score = isset($column[3]) ? mysqli_real_escape_string($new, $column[3]) : ""; $total_score = isset($column[4]) ? mysqli_real_escape_string($new, $column[4]) : ""; $position = isset($column[5]) ? mysqli_real_escape_string($new, $column[5]) : ""; $grading = isset($column[6]) ? mysqli_real_escape_string($new, $column[6]) : ""; $remarks = isset($column[7]) ? mysqli_real_escape_string($new, $column[7]) : ""; $class = isset($column[8]) ? mysqli_real_escape_string($new, $column[8]) : ""; $status = isset($column[9]) ? mysqli_real_escape_string($new, $column[9]) : ""; $teacher = isset($column[10]) ? mysqli_real_escape_string($new, $column[10]) : ""; // Insert data into the database if index_number is not empty if (!empty($index_number)) { $s_code = $_SESSION['s_code_Xw2119904']; $sqlo = mysqli_query($new, "INSERT INTO student_result(`index_number`, `subject`, `class_score`, `exams_score`, `total_score`, `position`, `grading`, `remarks`, `s_code`,`form`,`term`,`academicyear`,`programme`,`r_status`,`teacher`) VALUES ('$index_number', '$subject', '$class_score', '$exams_score', '$total_score', '$position', '$grading', '$remarks', '$s_code','$class', '$term', '$academic','$programme','$status','$teacher')"); echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Success!', text: 'Data uploaded successfully.', icon: 'success', confirmButtonText: 'OK' }); }); </script>"; } } } catch (Exception $e) { echo "<script> document.addEventListener('DOMContentLoaded', function() { Swal.fire({ title: 'Error!', text: 'Error reading the Excel file: " . addslashes($e->getMessage()) . "', icon: 'error', confirmButtonText: 'OK' }); }); </script>"; exit; } } if (isset($_POST["submit20"])) { // Retrieve form data $myindexno = isset($_POST['myindexno']) ? test_input($_POST['myindexno']) : ''; $semester = isset($_POST['semester']) ? test_input($_POST['semester']) : ''; $academic = isset($_POST['academic']) ? test_input($_POST['academic']) : ''; $PROGRAMME = isset($_POST['PROGRAMME']) ? test_input($_POST['PROGRAMME']) : ''; if (!empty($myindexno)) { echo "Selected Index: " . $myindexno; // Proceed with further processing like database queries, etc. } else { echo "Please select an index number."; } } } } ?> <!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <title>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> <style> table { width: 100%; border-collapse: collapse; margin: 20px auto; font-family: Arial, sans-serif; } th, td { border: 1px solid black; padding: 10px; text-align: center; } th { background-color: #f2f2f2; } td { background-color: #fff; } .grade-A1 { color: green; } .grade-B2 { color: blue; } .grade-B3 { color: orange; } </style> </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">SUBMIT 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">SUBMIT STUDENT RESULT</li> </ol> </div> </div> </div> </div> <!-- end page title --> <div class="row"> <button type="button" style="width:200px" class="btn btn-dark btn-rounded waves-effect waves-light me-3" data-bs-toggle="modal" data-bs-target=".bs-example-modal-lgcsv">Upload student result</button> <div class="container mt-4"> <!-- Row for aligning button and form --> <div class="d-flex align-items-center"> <!-- Upload Button --> <!-- Form --> <form method="POST" class="d-flex"> <!-- Dropdown for Student Index with margin to the right --> <select class="form-control me-4" name="academic" style="width: 400px;"> <option value="">---ACADEMIC YEAR---</option> <option value="2024/2025">2024/2025</option> <option value="2025/2026">2025/2026</option> <option value="2026/2027">2026/2027</option> <option value="2027/2028">2027/2028</option> </select> <select class="form-control me-4" name="myindexno" style="width: 400px;"> <option value="">--STUDENT INDEX--</option> <?php $homee = mysqli_query($new, "SELECT * FROM enrol_details WHERE s_code = '$s_code'"); if ($homee) { while ($gethousee = mysqli_fetch_array($homee)) { echo "<option value='" . $gethousee['index_no'] . "'>" . $gethousee['index_no'] . "</option>"; } } else { echo "Error: " . mysqli_error($new); // Debug SQL error } ?> </select> <!-- Dropdown for Semester with margin to the right --> <select class="form-control me-4" name="semester" required> <option value="">---SELECT---</option> <?php $selectt = mysqli_query($new,"SELECT * FROM semester WHERE s_code = '$s_code'"); while ($getdataa = mysqli_fetch_array($selectt)) { ?> <option value="<?php echo $getdataa['semester'];?>"><?php echo $getdataa['semester'];?></option> <?php }?> </select> <select class="form-control me-4" name="PROGRAMME" required> <option value="">---SELECT---</option> <?php $selectt = mysqli_query($new,"SELECT * FROM programme WHERE s_code = '$s_code'"); while ($getdataaA = mysqli_fetch_array($selectt)) { ?> <option value="<?php echo $getdataaA['program_name'];?>"><?php echo $getdataaA['program_name'];?></option> <?php }?> </select> <!-- Search button --> <button type="submit" name="submit20" class="btn btn-primary">Search</button> </form> </div> </div> <br /> <div class="col-12"> <h5>Index number : <?php echo $myindexno;?> </h5> <h5>Semester : <?php echo $semester;?></h5> <h5>Academic Year : <?php echo $academic;?></h5> <h5>Academic Year : <?php echo $PROGRAMME;?></h5> <div class="col-12"> <div class="table-responsive"> <table class="table table-bordered table-hover table-striped align-middle"> <thead class="table-dark text-center"> <tr> <th>SUBJECTS</th> <th>CLASS SCORE<br>30%</th> <th>EXAM SCORE<br>70%</th> <th>TOTAL SCORE<br>100%</th> <th>POSITION IN SUBJECT</th> <th>GRADING</th> <th>REMARKS</th> </tr> </thead> <tbody> <?php $cnt = 1; // Query with all required columns $select = mysqli_query($new,"SELECT * FROM student_result WHERE index_number = '$myindexno' and term = '$semester' AND programme = '$PROGRAMME'"); if ($select && mysqli_num_rows($select) > 0) { while ($get = mysqli_fetch_assoc($select)) { ?> <tr> <td><?php echo $get['subject'];?></td> <td><?php echo $get['class_score'];?></td> <td><?php echo $get['exams_score'];?></td> <td><?php echo $get['total_score'];?></td> <td><?php echo $get['position'];?></td> <td class="grade-A1"><?php echo $get['grading'];?></td> <td><?php echo $get['remarks'];?></td> </tr> <?php $cnt++; } mysqli_free_result($select); } else { ?> <tr> <td colspan="6"><?php echo $select ? 'No records found.' : 'Query error: ' . mysqli_error($new); ?></td> </tr> <?php } ?> </tbody> </table> </div> </div> <div class="modal fade bs-example-modal-lgcsv" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="myLargeModalLabel">Upload student result (Excel xlsx)</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <!-- Centering the form and limiting its width --> <div class="container"> <div class="row justify-content-center"> <form class="form-horizontal" method="POST" action="result-template.xlsx" enctype="multipart/form-data"> <div class="form-group"> <label for="firstname" class="col-sm-9 control-label"> Template</label> <div class="col-sm-9"> <input type="hidden" class="form-control" id="download" name="download" Value="download"> <button type="submit" class="btn btn-primary" name="add"><i class="fas fa-download"></i> Download Template</button> </div> </div> </form> <br /><br /><br /> <div class="col-md-8 col-lg-8"> <!-- Adjust the column size as needed --> <form method="POST" enctype="multipart/form-data"> <?php // echo csrf_token_tag(); ?> <div class="mb-4"> <label for="exampleInputEmail1" class="form-label">Select Semester</label> <select class="form-control" name="term" required> <option value="">---SELECT---</option> <?php $selectt = mysqli_query($new,"SELECT * FROM semester WHERE s_code = '$s_code'"); while ($getdataa = mysqli_fetch_array($selectt)) { ?> <option value="<?php echo $getdataa['semester'];?>"><?php echo $getdataa['semester'];?></option> <?php }?> </select> </div> <div class="mb-4"> <label for="exampleInputEmail1" class="form-label">Select programme</label> <select class="form-control" name="programme" required> <option value="">---SELECT---</option> <?php $selecttt = mysqli_query($new,"SELECT * FROM programme WHERE s_code = '$s_code'"); while ($getdataaa = mysqli_fetch_array($selecttt)) { ?> <option value="<?php echo $getdataaa['program_name'];?>"><?php echo $getdataaa['program_name'];?></option> <?php }?> </select> </div> <div class="mb-4"> <label for="exampleInputEmail1" class="form-label">Academy year</label> <select class="form-control" name="academic" required> <option value="">---ACADEMIC YEAR---</option> <option value="2024/2025">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 class="mb-4"> <label for="exampleInputEmail1" class="form-label">Choose file</label> <input type="file" class="form-control" accept=".xlsx" name="file" required> </div> <button type="submit" name="upload" class="btn btn-primary">Submit</button> </form> <br /><br/> </div> </div> </div> </div> </div> </div> </div> </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: 60.06 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