<?php
session_start();
include("db.php");
    if(isset($_POST['login'])){
        if(empty($_POST['username']) || empty($_POST['password'])){
            header("Location: index.php?Empty=Empty username or password");
        }else{
            $username = $_POST['username'];
        $password = $_POST['password'];

        $query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
        $result = mysqli_query($conn, $query);
        if(mysqli_num_rows($result) == 1){
                
                $_SESSION['User'] = $_POST['username'];
                header("Location: welcome.php");
            }else{
                header("Location: index.php?Invalid=Wrong username or password");
            }
        }
    }
?>
