Viewing file: submit.php (3.99 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE html> <html lang="en">
<?php include 'head.php';?>
<body>
<!-- ======= Header ======= --> <?php include 'menubar.php';?>
<?php include 'sidebar.php';?>
<main id="main" class="main">
<?php include 'connect.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// === Sanitize inputs === $enrollment = $_POST["student_id"]; $name = $_POST["name"]; $father = $_POST["father"]; $mother = $_POST["mother"]; $aadhar = $_POST["aadhar"]; $dob = $_POST["dob"]; $gender = $_POST["gender"]; $category = $_POST["category"]; $address = $_POST["address"]; $city = $_POST["city"]; $district = $_POST["district"]; $pincode = $_POST["pincode"]; $address1 = $_POST["address1"]; $city1 = $_POST["city1"]; $district1 = $_POST["district1"]; $pincode1 = $_POST["pincode1"]; $mobile = $_POST["mobile"]; $mobile2 = $_POST["mobile2"]; $email = $_POST["email"]; $session = $_POST["session"]; $password = $_POST["password"]; $branch = $_POST["branch"]; $year = $_POST["reg_year"]; $course = $_POST["course"]; $batchtime = $_POST["batch_time"]; $language = $_POST["language"]; $courseduration = $_POST["courseduration"]; $batchNo = $_POST["batch_no"]; $regDate = $_POST["day"] . '/' . $_POST["month"] . '/' . $_POST["year"]; $reg_month = $_POST["reg_month"]; $reg_year = $_POST["reg_year"]; $table_no = $_POST["table_no"]; $course_fees = $_POST["fees_amount"]; $certificate_issue_date = ""; // fill later if needed
// === Upload photo and signature === $photo = $_FILES["photo"]; $photo_name = basename($photo["name"]); $photo_tmp = $photo["tmp_name"]; $photo_path = "../data/files/" . $photo_name; move_uploaded_file($photo_tmp, $photo_path);
$signature = $_FILES["signature"]; $sign_name = basename($signature["name"]); $sign_tmp = $signature["tmp_name"]; $sign_path = "../data/files/" . $sign_name; move_uploaded_file($sign_tmp, $sign_path);
// === Check for duplicate enrollment === $check_sql = "SELECT * FROM admission WHERE enrollment = ?"; $check_stmt = $conn->prepare($check_sql); $check_stmt->bind_param("s", $enrollment); $check_stmt->execute(); $check_result = $check_stmt->get_result();
if ($check_result && $check_result->num_rows > 0) { echo "Duplicate Student ID"; exit; }
// === Insert into admission === $insert_sql = "INSERT INTO admission ( branch, regDate, enrollment, name, fatherName, motherName, aadhar, year, course, batchtime, language, courseduration, batchNo, dob, gender, category, address, city, district, pincode, address1, city1, district1, pincode1, mobile, email, signature, photo, session, password, mobile2, course_fees, certificate_issue_date, reg_date, reg_month, reg_year, table_no, batch_time ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
$stmt = $conn->prepare($insert_sql); if (!$stmt) { die("Prepare failed (admission): " . $conn->error); }
$stmt->bind_param( "ssssssssssssssssssssssssssssssssssssss", $branch, $regDate, $enrollment, $name, $father, $mother, $aadhar, $year, $course, $batchtime, $language, $courseduration, $batchNo, $dob, $gender, $category, $address, $city, $district, $pincode, $address1, $city1, $district1, $pincode1, $mobile, $email, $sign_name, $photo_name, $session, $password, $mobile2, $course_fees, $certificate_issue_date, $regDate, $reg_month, $reg_year, $table_no, $batchtime );
if ($stmt->execute()) { echo "<h2>Student Registered Successfully</h2>"; echo '<a href="update_registraion.php">Download Admission Slip</a>'; } else { echo "Error inserting record: " . $stmt->error; }
$stmt->close(); $conn->close(); } else { echo "Invalid Request"; } ?>
<?php include 'footer.php';?>
</body>
</html>
|