<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-4.6.2-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="styles.css">

    <link rel="shortcut icon" href="../Image/poly (2).png" type="image/x-icon" />
    <link rel="apple-touch-icon" href="../Image/poly (2).png">

</head>
<body>
   

    <div class="container">
    <div class="row">
        <div class="col-lg-4"></div>
        <div class="col-lg-4">
            <p class="title"></p>
            <p align="center" >
                <img src="images/envillepoly1.png" alt="" width="30%" height="30%" >
            </p>
            <h4 align="center">Sign in to student portal</h4>
            <form action="index.php" method="post" >
               
                 <div class="form-group">
                
                    <label for="">Matric no.</label>
                <input type="text" name="mat" class="form-control" placeholder="MatricNumber " required> <br>
            
            <label for="">Password </label>
                <input type="password" name="sname" class="form-control" placeholder="Surname" required> <br>
    
            <p align="right"><a href="">forgot password?</a></p>
                <button type="submit" name="btnsubmit" class="btn-block btn-success" >Sign in</button>
            </div>
            </form>
           
        </div>
        <div class="col-lg-4"></div>
    </div>  
</div> <br>

 <div class="container">
    <div class="row">
        <div class="col-lg-4"></div>
        <div class="col-lg-4">
            <p align="center" class="box">Take me home - <a href="https://envillepoly.edu.ng/">Go to college site</a></p>
          
        </div>
        <div class="col-lg-4"></div>
    </div>
 </div>
       
</body>
</html>
<?php
include("inc/db.php");
if(isset($_POST['btnsubmit'])){

//initialize your variable

$mat = mysqli_real_escape_string($db, $_POST['mat']);
$sname = mysqli_real_escape_string($db, $_POST['sname']);


$query ="SELECT * FROM portal where mat = '$mat' AND sname = '$sname'";

$query_result = $db->query($query);

if($query_result->num_rows == 1){
    session_start();
    // $_SESSION["mat"] = $mat;
    $_SESSION["sname"] = $sname;
    header("location:../index.php?env=dashboard");
    exit();
}else{
    echo "<script>alert('Oooop! Wrong Email or Password')</script>";
}

// $query_result= mysqli_query ($db, $query);
// if(mysqli_fetch_array($query_result) > 0){
//     header("location:../index.php?env=dashboard");
// }else{
//     echo "<script>alert('Oooop! Wrong Email or Password')</script>";
// }
}
?>