<?php
session_start();                  
$username=$_POST['cand_username'] ?? '';
$_SESSION['username'] = $username;
$password=$_POST['cand_password'] ?? '';
$_SESSION['password'] = $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 nif_pass='$password' AND act_vate='1'");
$login_check = mysqli_num_rows($sql);
if($login_check > 0){
$row = mysqli_fetch_assoc($sql);
$xadmnchk=$row['dept_x'];
					$sql = mysqli_query($conn, "INSERT INTO user_log_login (log_date, user_id, ip)
					VALUES(now(),'$username','$ip')")
					or die (mysqli_error($conn));
	echo "<meta http-equiv=Refresh content=1;url=pat_3.php>";
}else {
echo ("<SCRIPT LANGUAGE='JavaScript'> window.location.href='invalidlogin.html'; </SCRIPT>");
}
?>
