<?php 

$host = "localhost"; 
$username = "root";
$password = "";
$dbname = "WSAS";

$con = mysqli_connect($host, $username, $password, $dbname);

if (!$con) {
    die("Connection failed! " . mysqli_connect_error());
}

if($_SERVER['REQUEST_METHOD'] == 'POST') {

    $course_id = $_POST['course_id']; 
    $course_code = $_POST['course_code'];
    $course_name = $_POST['course_name'];
    $major = $_POST['major'];

    $sql = "INSERT INTO admincourse (course_id, course_code, course_name, major) 
            VALUES ('$course_id','$course_code','$course_name','$major')";

    $rs = mysqli_query($con, $sql);

    if($rs) {
        header("Location: ../adminpanel/admincourse.php");
        exit;
    } else {
        echo "Error: " . mysqli_error($con);
    }
}

mysqli_close($con);

?>