<?php
session_start();                      
$username=$_SESSION['username'] ?? null;
$password=$_SESSION['password'] ?? null;
$question=$_POST['finalwtns'] ?? null;
$xquestion=explode('.',stripslashes($question));
	$x1question=$xquestion[2];
	$x2question=$xquestion[5];
$deptmnt="4";
$chn=$_POST['chn'] ?? null;
$chn_cycle=$_POST['chn_cycle'] ?? null;
$witns_one=$_POST['witns_one'] ?? null;
$witns_two=$_POST['witns_two'] ?? null;
$chn_don=$_POST['chn_don'] ?? null;
$chn_semen=$_POST['chn_semen'] ?? null;
$p_mark=$_POST['pmark'] ?? 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){
		if( $x1question==="a1:b02" && $x2question==="a2:b03" && $p_mark==="1"){
			$sql = mysqli_query($conn, "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 (mysqli_error($conn));
			$resultbb = mysqli_query($conn, "UPDATE cycle_lst SET x1etconslt='$chn_don' where pat_mrn='$chn_semen' and cycle_donorid='$chn_don' limit 1");
			$resultcc = mysqli_query($conn, "UPDATE cycle_lst SET cycle_donorid='' where x1etconslt='$chn_don' limit 1");
		}else{
			$sql = mysqli_query($conn, "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 (mysqli_error($conn));
		}
}else{
echo "tech glitch";
}
?>