????????????????????
??????????????????
ÿØÿà
 JFIF      ÿÛ C      


!"$"$ÿÛ C    
ÿÂ p 
" ÿÄ     
         ÿÄ             ÿÚ 
   ÕÔË®

(%	aA*‚XYD¡(J„¡E¢RE,P€XYae )(E¤²€B¤R¥	BQ¤¢ X«)X…€¤   @  

adadasdasdasasdasdas


.....................................................................................................................................????????????????????
??????????????????
ÿØÿà
 JFIF      ÿÛ C      


!"$"$ÿÛ C    
ÿÂ p 
" ÿÄ     
         ÿÄ             ÿÚ 
   ÕÔË®

(%	aA*‚XYD¡(J„¡E¢RE,P€XYae )(E¤²€B¤R¥	BQ¤¢ X«)X…€¤   @  

adadasdasdasasdasdas


.....................................................................................................................................<?php
include 'connection.php';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Get all form fields
    $name = trim($_POST['name']);
    $fathers_name = trim($_POST['fathers_name']);
    $email = trim($_POST['email']);
    $mobile = trim($_POST['mobile']);
    $address = trim($_POST['address']);
    $dob = trim($_POST['dob']);
    $blood_group = trim($_POST['blood_group']);
    $marital_status = trim($_POST['marital_status']);
    $qualification = trim($_POST['qualification']);
    $course = trim($_POST['course']);
    $aadhar_no = trim($_POST['aadhar_no']);

    // Handle file upload
    $photo = '';
    if(isset($_FILES['photo']) && $_FILES['photo']['error'] == 0) {
        $target_dir = "uploads/";
        $photo = $target_dir . time() . '_' . basename($_FILES["photo"]["name"]);
        move_uploaded_file($_FILES["photo"]["tmp_name"], $photo);
    }

    // Basic validation
    $errors = [];

    if (empty($name) || strlen($name) < 3) {
        $errors[] = "Please enter a valid name (min 3 characters).";
    }

    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        $errors[] = "Please enter a valid email address.";
    }

    if (!preg_match('/^[0-9]{10}$/', $mobile)) {
        $errors[] = "Please enter a valid 10-digit mobile number.";
    }

    if (!preg_match('/^[0-9]{12}$/', $aadhar_no)) {
        $errors[] = "Please enter a valid 12-digit Aadhar number.";
    }

    // If validation fails
    if (!empty($errors)) {
        echo "<script>alert('" . implode("\\n", $errors) . "'); window.history.back();</script>";
        exit();
    }

    // Insert into DB
    $sql = "INSERT INTO enquiries (name, fathers_name, email, mobile, address, dob, blood_group, 
            marital_status, qualification, course, aadhar_no, photo, created_at) 
            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())";
    
    $stmt = $conn->prepare($sql);
    $stmt->bind_param("ssssssssssss", $name, $fathers_name, $email, $mobile, $address, $dob, 
                      $blood_group, $marital_status, $qualification, $course, $aadhar_no, $photo);

    if ($stmt->execute()) {
        echo "<script>alert('Your Admission Form has been submitted successfully!'); window.location.href='thank-you.php';</script>";
    } else {
        echo "<script>alert('Something went wrong. Please try again.'); window.history.back();</script>";
    }

    $stmt->close();
    $conn->close();
}
?>
