<?php
session_start();                  
$username=$_POST['cand_username'] ?? '';
$password=$_POST['cand_password'] ?? '';

$ip=$_SERVER['REMOTE_ADDR'] ?? '';

$xcentr = $_POST['xcentr'] ?? '';
include 'dbcon.php';
$password=md5($password);

$sql = mysqli_query($conn, "SELECT * FROM matcher_usermst WHERE nif_usr='$username' AND act_vate='1'");

$login_check = mysqli_num_rows($sql);
if($login_check > 0){
	$_SESSION['username'] = $username;
	$_SESSION['password'] = $_POST['cand_password'] ?? '';
	$_SESSION['logged_in'] = true;
$row = mysqli_fetch_assoc($sql);
$xadmnchk=$row['dept_x'];
					$sql = mysqli_query($conn, "INSERT INTO user_log_login (log_date, user_id, ip, deprtmnt) VALUES(now(),'$username','$ip','4')")
					or die (mysqli_error($conn));
echo "<meta http-equiv=Refresh content=1;url=main_wlcm_ivflabn.php>";
}else {
echo "Invalid login";
}
?>
