hjkhhndndndnd,trt
bnmbertsu,yu,yu,fffffffy,ltdfg
/
home4
/
gofvotmy
/
public_html
/
shs_admission
/
Upload FileeE
HOME
<?php include 'connection.php'; error_reporting(E_ALL); session_start(); if (isset($_POST['Submit'])) { // Define the SQL query with placeholders $insert = "INSERT INTO shs_registration (Student_Name, DOB, Student_Photo, Religion, Nationality, Category, Category_Cert, Address, Mother_Name, Mother_Qual, Mother_Prof, is_mother_ex_student, is_mother_govt_employee, Father_Name, Father_Qual, Father_Prof, is_father_govt_employee, Tel, Distance_From_School, Medical_Cond, Name_Address_Pre_School, Sibbling_Studying, Sibbling_Name_Class, Latest_Report_Card, DOB_Cert, Parents_Adhaar) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; // Create a prepared statement $stmt = mysqli_prepare($con, $insert); if ($stmt) { // Handle image file upload if ($_FILES['student_photo']['error'] === UPLOAD_ERR_OK) { $uploadDir = 'uploads/images/'; // Define the directory where you want to store images $uploadFile = $uploadDir . basename($_FILES['student_photo']['name']); if (move_uploaded_file($_FILES['student_photo']['tmp_name'], $uploadFile)) { // Set the image file path $studentPhoto = $uploadFile; } else { echo "Error uploading student photo."; exit; // Terminate the script if there's an error } } else { echo "Error: " . $_FILES['student_photo']['error']; exit; // Terminate the script if there's an error } // Handle PDF file upload (e.g., report card) if ($_FILES['pdf_report_card']['error'] === UPLOAD_ERR_OK) { $uploadDir = 'admin/uploads/report_card/'; // Define the directory where you want to store PDFs $uploadFile = $uploadDir . basename($_FILES['pdf_report_card']['name']); if (move_uploaded_file($_FILES['pdf_report_card']['tmp_name'], $uploadFile)) { // Set the PDF file path $latestReportCard = $uploadFile; } else { echo "Error uploading PDF report card."; exit; // Terminate the script if there's an error } } else { echo "Error: " . $_FILES['pdf_report_card']['error']; exit; // Terminate the script if there's an error } // Handle DOBCert file upload if ($_FILES['dob_cert']['error'] === UPLOAD_ERR_OK) { $uploadDir = 'uploads/dob_certs/'; // Define the directory where you want to store DOBCert files $uploadFile = $uploadDir . basename($_FILES['dob_cert']['name']); if (move_uploaded_file($_FILES['dob_cert']['tmp_name'], $uploadFile)) { // Set the DOBCert file path $DOBCert = $uploadFile; } else { echo "Error uploading DOBCert."; exit; // Terminate the script if there's an error } } else { echo "Error: " . $_FILES['dob_cert']['error']; exit; // Terminate the script if there's an error } // Handle parentsAdhaar file upload if ($_FILES['aadhaar']['error'] === UPLOAD_ERR_OK) { $uploadDir = 'uploads/aadhaar/'; // Define the directory where you want to store parentsAdhaar files $uploadFile = $uploadDir . basename($_FILES['aadhaar']['name']); if (move_uploaded_file($_FILES['aadhaar']['tmp_name'], $uploadFile)) { // Set the parentsAdhaar file path $parentsAdhaar = $uploadFile; } else { echo "Error uploading parentsAdhaar."; exit; // Terminate the script if there's an error } } else { echo "Error: " . $_FILES['aadhaar']['error']; exit; // Terminate the script if there's an error } if ($_POST['category'] === 'General') { $categoryCert = null; // Set to NULL if 'General' is selected } else { if ($_FILES['cat_cert']['error'] === UPLOAD_ERR_OK) { $uploadDir = 'uploads/cat_cert/'; // Define the directory where you want to store Category Certificate PDFs $uploadFile = $uploadDir . basename($_FILES['cat_cert']['name']); if (move_uploaded_file($_FILES['cat_cert']['tmp_name'], $uploadFile)) { // Set the Category Certificate PDF file path $categoryCert = $uploadFile; } else { echo "Error uploading Category Certificate."; exit; // Terminate the script if there's an error } } else { echo "Error: " . $_FILES['cat_cert']['error']; exit; // Terminate the script if there's an error } } // if ($_FILES['cat_cert']['error'] === UPLOAD_ERR_OK) { // $uploadDir = 'uploads/cat_cert/'; // Define the directory where you want to store parentsAdhaar files // $uploadFile = $uploadDir . basename($_FILES['cat_cert']['name']); // if (move_uploaded_file($_FILES['cat_cert']['tmp_name'], $uploadFile)) { // // Set the parentsAdhaar file path // $categoryCert = $uploadFile; // } else { // echo "Error uploading Category Certificate."; // exit; // Terminate the script if there's an error // } // } else { // echo "Error: " . $_FILES['cat_cert']['error']; // exit; // Terminate the script if there's an error // } // Bind the parameters mysqli_stmt_bind_param($stmt, 'ssssssssssssssssssssssssss', $studentName, $DOB, $studentPhoto, $religion, $nationality, $category, $categoryCert, $address, $motherName, $motherQual, $motherProf, $isMotherExStudent, $isMotherGovtEmployee, $fatherName, $fatherQual, $fatherProf, $isFatherGovtEmployee, $tel, $distanceFromSchool, $medicalCond, $nameAddressPreSchool, $siblingStudying, $siblingNameClass, $latestReportCard, $DOBCert, $parentsAdhaar); // Set parameter values for other input fields $studentName = $_POST['candidate_name']; $DOB = $_POST['dob']; $religion = $_POST['religion']; $nationality = $_POST['nationality']; $category = $_POST['category']; // $categoryCert = isset($_POST['cat_cert']) ? $_POST['cat_cert'] : null; $address = $_POST['address']; $motherName = $_POST['mother_name']; $motherQual = $_POST['mother_qualification']; $motherProf = $_POST['mother_profession']; $isMotherExStudent = $_POST['is_mother_ex_student']; $isMotherGovtEmployee = $_POST['is_mother_govt_employee']; $fatherName = $_POST['father_name']; $fatherQual = $_POST['father_qualification']; $fatherProf = $_POST['father_profession']; $isFatherGovtEmployee = $_POST['is_father_govt_employee']; $tel = $_POST['telephone']; $distanceFromSchool = $_POST['distance_from_school']; $medicalCond = $_POST['medical']; $nameAddressPreSchool = $_POST['previous_school_address']; $siblingStudying = $_POST['sibling']; $siblingNameClass = isset($_POST['class_section']) ? $_POST['class_section'] : null; if (mysqli_stmt_execute($stmt)) { echo '<script>alert("Registration Successfully");</script>'; echo '<script>window.location.href="test.php";</script>'; exit(); } else { ?> <!-- echo "Error: " . mysqli_error($con); --> <script> alert("Error"); </script> <?php } // Close the prepared statement mysqli_stmt_close($stmt); } else { echo "Error in preparing the statement."; } // Close the database connection mysqli_close($con); } ?>