File "approval_add.php"

Full Path: /home/scheduling/public_html/faculty/admin/function/approval_add.php
File size: 912 bytes
MIME-type: text/x-php
Charset: utf-8

<?php
include "../../include/conn.php"; // Adjust path

// ✅ Validate required fields
if (isset($_POST['curriculum_id'], $_POST['name'], $_POST['degree'], $_POST['position'], $_POST['type'])) {
    $curriculum_id = intval($_POST['curriculum_id']);
    $name = $conn->real_escape_string(trim($_POST['name']));
    $degree = $conn->real_escape_string(trim($_POST['degree']));
    $position = $conn->real_escape_string(trim($_POST['position']));
    $type = $conn->real_escape_string(trim($_POST['type']));

    // ✅ Insert into approval table
    $sql = "INSERT INTO approval (curriculum_id, name, degree, position, type) 
            VALUES ('$curriculum_id', '$name', '$degree', '$position', '$type')";

    if ($conn->query($sql)) {
        echo "success";
    } else {
        echo "Database error: " . $conn->error;
    }
} else {
    echo "Please fill all required fields.";
}
?>