<?php
session_start();                      
$username=$_SESSION['username'] ?? null;
$password=$_SESSION['password'] ?? null;
$chn=$_GET['chn'] ?? null;
$ip=$_SERVER['REMOTE_ADDR'] ?? null;
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'];

$myfile = fopen("txiv834a.txt", "w") or die("Unable to open file!");
$txt = "";
fwrite($myfile, $txt);
fclose($myfile);
$myfile1 = fopen("txiv834.txt", "w") or die("Unable to open file!");
$txt1 = "";
fwrite($myfile1, $txt1);
fclose($myfile1);


}else {
	session_destroy();
echo "Invalid login";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
INPUT { margin-right: 1em }
</style>
<link href="../style.css" rel="stylesheet" type="text/css" />
<link href="style_btn.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js_button.js"></script>
<link href="../style_btn.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js_button.js"></script>
<style>
#Image {
    margin: 5px;
    border:2px solid #FF3399;
    border-radius: 5px;
    background-size: 210px;
    background-position:center;
}
#Imagex {
    margin: 5px;
    border:2px solid #FF3399;
	width:200px;
	height:200px;
    border-radius: 10px;
    background-size: 210px;
    background-position:center;
}
#foo {
    position: fixed;
    top: -1000000px;
  }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script>
function myFunction() {

	var timer = null;
	$('#ptcard').keydown(function(){
		   clearTimeout(timer); 
		   timer = setTimeout(doStuff, 100)
	});
	function doStuff() {
	var value = document.getElementById('ptcard').value;
	 if (value.length < 9) {
		document.getElementById('ptcard').value = '';
	 }
	}


var ptcard = document.getElementById("ptcard").value;
	if (ptcard.length == 9){
		window.location.href="gend_cycle_select.php?chn="+ptcard;
	}else{
	}
}
function lctfrst() {
document.getElementById("ptcard").focus();
document.getElementById('ptcard').value = '';
}
</script>
</head>
<body onLoad="lctfrst()">
<div id="foo"><input name="ptcard" id="ptcard" type="text" onKeyUp="myFunction()"></div>
<br><br><br><br><br><br><br><div align="center"><img src="strtupmain.jpg"/></div><br><br>
<div style="color:#006699;font-size:20px;text-align:center">Welcome to NOVA IVF Electronic Witnessing System - EMBRYOLOGY DEPARTMENT</div><br><br><br><br><br>
<div style="color:#FF6600;font-weight:700;font-size:16px;text-align:center">Scan patient card to proceed ....</div><br><br><br><br><br>
<div style="color:#330000;font-weight:700;font-size:16px;text-align:center"><a href="main_wlcm_ivflabn.php">Refresh screen ....</a></div>
</body>
</html>