<?php

    session_start();

    include "../db.php";

    date_default_timezone_set('Asia/Kolkata');

    $currentTime = date('M j, Y g:i a');



    if ( !isset($_SESSION['uid']) && !isset($_SESSION['uref']) && !isset($_SESSION['utype']) && !isset($_SESSION['uname']) )

        header("Location: logout.php");

?>

<!DOCTYPE html>

<html lang="en">

<head>

 <?php include "includes/meta.php"; ?>        

    <?php include "includes/css.php"; ?>     

  



</head>

<body id="page-top" class="mt-55">



    <div style="margin-top: 130px;"></div>



      <?php include "includes/header2.php"; ?>

<div class="container">

                    <div class="row justify-content-center">

                    <div class="col-md-8">

                        <div class="card shadow mt-3">

                        <h5 class="card-header text-dark  text-center font-weight-bold"> Add class</h5>

                            <div class="card-body">

                                <form method="POST">

                                    <div class="row mt-4">

                                        <div class="col-md-12">

                                            <label class="badge badge-warning text-dark">Class</label>

                                            <input type="text" class="form-control" id="sclass" placeholder="Enter class" name="sclass" required>

                                        </div>

                                    </div>

                                    <div class=" row justify-content-center">

                                        <button type="submit" class="btn btn-success text-sm-center mt-4" name="submit">

                                            <i class="fa fa-upload"></i> Upload

                                        </button>

                                    </div>

                                </form>

                            </div>

                        </div>

                    </div>

                </div>

            </div>

                <?php



if(isset($_POST['submit'])){

    $sclass = mysqli_real_escape_string($con, strip_tags($_POST['sclass']));

        $ins_sql = "INSERT INTO class (sclass, uploadedby, sdate) VALUES ('$sclass', '$_SESSION[uref]', '$currentTime')";

        //  echo "<pre>";print_r($ins_sql);exit();





        if(mysqli_query($con, $ins_sql)){

            ?>

            <script>window.location = 'view-class.php';</script>

            <?php

        }

        else{

            ?>

            <script>

                alert('OOPS !!!!');

                setTimeout(() => {

                    window.location = 'add-class.php';

                }, 1200);

            </script>

            <?php

        }

    } 



?>



<div style="margin-top: 260px;"></div>

            <?php include "includes/ft.php"; ?>

            <?php include "includes/js.php"; ?>



    <script src="js/jquery.min.js"></script>

    <script src="js/bootstrap.min.js"></script>

    <script src="js/jquery.easing.min.js"></script>

    <script src="js/sb-admin-2.min.js"></script>

    <script src="js/sweetalert2.min.js"></script>

    <script src="js/jquery.dataTables.min.js"></script>

    <script src="js/dataTables.bootstrap4.min.js"></script>

    <script src="js/datatables.mark.min.js"></script>

    <script src="js/jquery-ui-custom.min.js"></script>

    <script src="js/custom.js"></script>



   

</body>

</html>







