<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '../auth/auth.php';
require_once '../models/db_connection.php';
require_once '../models/course_model.php';
$course =  new Course($conn);

if (isset($_POST['addCourse'])) {
  $coursename = $_POST['course'];
  $desc = $_POST['desc'];
  $price = $_POST['price'];
  $course->addCourse($coursename,$price, $desc);
  header("Location: view_course.php?message=Course added successfully");
  exit(); // Stop further execution
}




?>
<!DOCTYPE html>
<html lang="en">

<head>
  <title>Student | Add Student </title>
  <?php include("../templates/header.php"); ?>
</head>

<body>
  <div class="container-scroller">
    <!-- partial:partials/_navbar.html -->
    <?php include("../templates/nav.php"); ?>
    <!-- partial -->
    <div class="container-fluid page-body-wrapper">
      <!-- partial:partials/_sidebar.html -->
      <?php include("../templates/sidenav.php"); ?>
      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
          <div class="col-md-6 grid-margin stretch-card">
            <div class="card">
              <div class="card-body">
                <h4 class="card-title">Add Course</h4>
                <p class="card-description">
                  Add Course <code></code>
                </p>
                <form action="add_course.php" method="POST">

                  <div class="form-group">
                    <label for="exampleFormControlSelect2">Course Name</label>
                    <input type="text" class="form-control" name="course" required>
                  </div>
                  <div class="form-group">
                    <label for="exampleFormControlSelect2">Course Price</label>
                    <input type="text" class="form-control" name="price" required>
                  </div>
                  <div class="form-group">
                    <label for="exampleFormControlSelect2">Course Duration </label>
                    <input type="text" class="form-control" name="desc" required>
                  </div>



                  <div class="col-sm-9">
                    <button type="submit" name="addCourse" class="btn btn-dark btn-lg ">Add Course</button>
                  </div>
              </div>
              </form>
            </div>
          </div>

        </div>
        <!-- content-wrapper ends -->
        <!-- partial:partials/_footer.html -->
        <?php include("../templates/footer.php"); ?>

        <!-- partial -->
      </div>
      <!-- main-panel ends -->
    </div>
    <!-- page-body-wrapper ends -->
  </div>
  <?php include("../templates/inc_scripts.php"); ?>
</body>

</html>