<?php
    session_start();
    include_once('users.php');

    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        $login = htmlspecialchars($_POST['login']);
        $passwd = htmlspecialchars($_POST['passwd']);
        
        if (array_key_exists($login, $users) && $passwd == $users[$login]) {
            $_SESSION['login'] = $login;
            header('Location: welcome.php');
        } else {
        $_SESSION['message'] = "Bad username or password";
            header('Location: signin.php');
        }
    } else {
        header('Location: signin.php');
    }
