<?php
function alogin($username, $password){
    $query = "SELECT * FROM `candidates` WHERE `email` = '$username' AND `password` = '$password'";
    $result = exe($query);
    if(mysqli_num_rows($result) > 0){
        $candidate = getCanditateByEmail($username);
        $candidateId = $candidate['id'];
        $_SESSION['candidate'] = $candidateId;
        header('location: profile');
    }else{
        array_push($GLOBALS['errors'], "Wrong username or password");
    }
}
?>