<?php
session_start();                      
$username=$_SESSION['username'] ?? '';
$password=$_SESSION['password'] ?? '';
$question=$_POST['finalwtns'] ?? '';
$deptmnt="4";
$chn=$_POST['chn'] ?? '';
$chn_cycle=$_POST['chn_cycle'] ?? '';
$witns_one=$_POST['witns_one'] ?? '';
$witns_two=$_POST['witns_two'] ?? '';
$chn_don=$_POST['chn_don'] ?? '';
$chn_semen=$_POST['chn_semen'] ?? '';
$p_mark=$_POST['pmark'] ?? '';
include 'dbcon.php';
$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){
		if($p_mark==="1"){
				$strngpart = "a2:b03";
				if (strpos($question, $strngpart) !== false) {
			$sql = mysql_query("INSERT INTO matcher_trans (reslt_dt, ent_by, chn, chn_cycle, witns_one, witns_two, chn_don, chn_semen, finalwitnsd, p_mark, witns1pnt)
			VALUES(now(), '$username', '$chn', '$chn_cycle', '$witns_one', '$witns_two', '$chn_don','$chn_semen','$question', '$p_mark','2')") or die (mysql_error());
			$resultbb = mysql_query("UPDATE cycle_lst SET x1etconslt='$chn_don' where pat_mrn='$chn_semen' and cycle_donorid='$chn_don' limit 1");
			$resultcc = mysql_query("UPDATE cycle_lst SET cycle_donorid='' where x1etconslt='$chn_don' limit 1");
				}else{
					$sql = mysql_query("INSERT INTO matcher_trans (reslt_dt, ent_by, chn, chn_cycle, witns_one, witns_two, chn_don, chn_semen, finalwitnsd, p_mark, witns1pnt)
					VALUES(now(), '$username', '$chn', '$chn_cycle', '$witns_one', '$witns_two', '$chn_don','$chn_semen','$question', '2','0')") or die (mysql_error());
				}
		}else{
			$sql = mysql_query("INSERT INTO matcher_trans (reslt_dt, ent_by, chn, chn_cycle, witns_one, witns_two, chn_don, chn_semen, finalwitnsd, p_mark, witns1pnt)
			VALUES(now(), '$username', '$chn', '$chn_cycle', '$witns_one', '$witns_two', '$chn_don','$chn_semen','$question', '$p_mark','0')") or die (mysql_error());
		}
}else{
echo "tech glitch";
}
?>