<?php
session_start();                      
$username=$_SESSION['username'] ?? '';
$password=$_SESSION['password'] ?? '';

$chn = $_POST['mychn'] ?? '';
$chnx = $_POST['idscan'] ?? '';

include 'dbcon.php';
if($chn==$chnx){
$xcyc=$_GET['mycycle'] ?? '';
$ip=$_SERVER['REMOTE_ADDR'] ?? '';
$password=md5($password);
$sql = mysql_query("SELECT * FROM matcher_usermst WHERE nif_usr='$username' AND nif_pass='$password' AND act_vate='1'");
$login_check = mysql_num_rows($sql);
	if($login_check > 0){
		$sql1 = mysql_query("SELECT * FROM actvty_trans_frzng_oocyt WHERE pat_id like '%$chn%' AND cycle_id='$xcyc' and actvty=''");
		$login_check2 = mysql_num_rows($sql1)+1; //1
		$trmdate = date('Y-m-d', strtotime('+ 6 months'));
			$sql = mysql_query("INSERT INTO actvty_trans_frzng_oocyt (log_no,strow_no,due_date_act, term_date, pat_id, cycle_id, actvty, user_id)
			VALUES('','$login_check2',Now(),'$trmdate', '$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>
