<?php
    include_once "includes/init.php"; 
    include 'includes/connection.php';
    $msg = "";

    // if (isset($_GET['verification'])) {
    //     if (mysqli_num_rows(mysqli_query($conn, "SELECT * FROM student_soes WHERE code='{$_GET['verification']}'")) > 0) {
    //         $query = mysqli_query($conn, "UPDATE student_soes SET code='' WHERE code='{$_GET['verification']}'");
            
    //         if ($query) {
    //             $msg = "<div class='alert alert-success'>Account verification has been successfully completed.</div>";
    //         }
    //     } else {
    //         header("Location: index.php");
    //     }
    // } 
    if (isset($_POST['login'])) {
        $email = mysqli_real_escape_string($conn, $_POST['username']);
        $password = mysqli_real_escape_string($conn, md5($_POST['password'])); 
        $sql = "SELECT * FROM teacher_srms WHERE user_email='{$email}' AND user_password='{$password}'";
        $result = mysqli_query($conn, $sql);

        if (mysqli_num_rows($result) === 1) {
            $row = mysqli_fetch_assoc($result);
            $_SESSION['user_email'] = $email; 
            $_SESSION['user_type']=$row['user_type'];
            $_SESSION['user_contact_no']=$row['user_contact_no'];
            $_SESSION['class_id']=$row['class_id'];
            if ($row['user_type'] === 'Academic Master') {
                $_SESSION['student_email_id'] = $email;
                header("location:admin/admin.php?page=dashboad");
            } else {
               header('location:admin/admin.php?page=profile');
            }
        } else {
            $msg = "<div class='alert alert-danger'>Email or password do not match.</div>";
        }
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <link rel="icon" type="image/jpg" href="assets/img/logo.png">
  <title>SARMS | Sikirari Accademic Result Management System</title> 
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="stp_con/fontawesome-free/css/all.min.css">
  <!-- overlayScrollbars -->
  <link rel="stylesheet" href="stp_con/overlayScrollbars/css/OverlayScrollbars.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="assets/css/adminlte.min.css">  
  <!-- daterange picker -->
  <link rel="stylesheet" href="stp_con/daterangepicker/daterangepicker.css">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="stp_con/icheck-bootstrap/icheck-bootstrap.min.css">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="stp_con/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css">
  <!-- Tempusdominus Bootstrap 4 -->
  <link rel="stylesheet" href="stp_con/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
  <!-- Select2 -->
  <link rel="stylesheet" href="stp_con/select2/css/select2.min.css">
  <link rel="stylesheet" href="stp_con/select2-bootstrap4-theme/select2-bootstrap4.min.css">
  <!-- Bootstrap4 Duallistbox -->
  <link rel="stylesheet" href="stp_con/bootstrap4-duallistbox/bootstrap-duallistbox.min.css">
  <!-- BS Stepper -->
  <link rel="stylesheet" href="stp_con/bs-stepper/css/bs-stepper.min.css">
  <!-- dropzonejs --> 
   <link href="assets/css/sb-admin-2.min.css" rel="stylesheet">
    
    <link rel="stylesheet" type="text/css" href="stp_con/parsley/parsley.css"/>
</head>
<body class="hold-transition login-page">

<div class="login-box">

  <!-- /.login-logo -->
 <div class="container-fluid">
  <div class="row">

    <div class="col-md-12">
    <!-- Widget: user widget style 1 -->
    <div class="card card-widget widget-user card-info card-outline">
      <!-- Add the bg color to the header using any of the bg-* classes -->
     <div class="widget-user-header text-white"
           style="background: url('assets/img/bac1.jpg') center center;size: 20%">
        <h3 class="widget-user-username text-right">SARMS</h3>
        <h5 class="widget-user-desc text-right">Login</h5>
      </div> 
      <div class="widget-user-image">
        <img class="img-circle" src="assets/img/logo.png" alt="User Avatar">
     </div> 

    <div class="card-body"> 
    <center><p><strong>SIKIRARI SEC SCHOOL</strong><br>Academic Result Management System</p></center> 

       <?php echo $msg; ?>   
      <form action="" method="post" id="login_form"> 
        <div class="form-group">
        
          <input type="text" id="username" name="username" class="form-control"  required autofocus data-parsley-type="email" data-parsley-trigger="keyup" placeholder="Enter Email Address...">
        
        </div>
        <div class="form-group">
        
            <input type="password" id="password" name="password" class="form-control"  required  data-parsley-trigger="keyup" placeholder="Password" >
          
        </div>
        <div class="row">
          <div class="col-6"> 
          </div>
          <!-- /.col -->
          <div class="col-6">
            <button type="submit" value="Login"  name="login" class="btn btn-info btn-block">Log In </button>
          </div>
          <!-- /.col -->
        </div>
      </form>  
      <hr>
        <center><span style="font-size: 18px;">&copy;</span>2025</center>
    </div>
    <!-- /.card-body -->
  </div>
</div>
</div>
</div>

  <!-- /.card -->
</div>
<hr> 
<!-- /.login-box -->

<!-- jQuery -->
<script src="stp_con/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="stp_con/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
 <script src="assets/js/sb-admin-2.min.js"></script> 
<script type="text/javascript" src="stp_con/parsley/dist/parsley.min.js"></script>
<script src="assets/js/adminlte.min.js"></script>
</body>
</html>
<script>

$(document).ready(function(){

    $('#login_form').parsley();
 
});

</script>

















