    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Student Portal</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="../images/cisn-logo.png" type="image/x-icon" />
    <link rel="apple-touch-icon" href="../images/cisn-logo.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="image/envillepoly.jpg" alt="" width="30%" height="30%" >
            </p>
            <h4 align="center">New Student Portal</h4>
            <form action="index.php" method="post" >
               
                 <div class="form-group">
                
                    <label for="">Email</label>
                <input type="text" name="email" class="form-control" placeholder="Email " 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://cisn.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

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


$query ="SELECT * FROM student_table where email = '$email' AND sname = '$sname'";

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

if($query_result->num_rows == 1){
    session_start();
    // $_SESSION["email"] = $email;
    $_SESSION["sname"] = $sname;
    header("location:../index.php?env=dashboard");
    exit();
}else{
    echo "<script>alert('Oooop! Wrong Username and 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>";
// }
}
?>