<?php
session_start();                      
$username=$_SESSION['username'] ?? null;
$password=$_SESSION['password'] ?? null;
$chn=$_GET['mychn'] ?? null;
$chnx=$_GET['idscan'] ?? null;
include 'dbcon.php';
if($chn==$chnx){
$xcyc=$_GET['mycycle'] ?? null;
$ip=$_SERVER['REMOTE_ADDR'] ?? null;
$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){
		$sql1 = mysqli_query($conn, "SELECT * FROM actvty_trans_frzng_oocyt WHERE pat_id like '%$chn%' AND cycle_id='$xcyc' and actvty=''");
		$login_check2 = mysqli_num_rows($sql1)+1; //1
			$sql = mysqli_query($conn, "INSERT INTO actvty_trans_frzng_oocyt (log_no,strow_no,due_date_act, pat_id, cycle_id, actvty, user_id)
			VALUES('','$login_check2',Now(), '$chn', '$xcyc', '$actvty_nm', '$username')");
			echo "<meta http-equiv=Refresh content=1;url=gend_cycle_select.php?chn=$chn>";
	}else {
	session_destroy();
	echo ("<SCRIPT LANGUAGE='JavaScript'> window.location.href='invalidlogin.html'; </SCRIPT>");
	}
}else{
echo "ID not matched";
echo "<meta http-equiv=Refresh content=2;url=gend_cycle_select.php?chn=$chn>";
}
?>
<!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>
</head>
<body>
</body>
</html>