<?php

  include('db_con.php');
//  var_dump($_POST);

?>

<?php

if(!empty($_POST["uid"])){

	$uid = mysqli_real_escape_string($con,$_POST['uid']);
	$sname = mysqli_real_escape_string($con,$_POST['sname']);

	$sql = "select * from applicant_table WHERE givenname LIKE '$uid' and surname LIKE '$sname'";

	$result = mysqli_query($con,$sql);

	if(mysqli_num_rows($result)){

		$row = mysqli_fetch_array($result);
		
		$sql = "select docp_name from doc_position_table WHERE `docp_id`='$row[doc_position]'";
		$result = mysqli_query($con,$sql);
		$namerow = mysqli_fetch_array($result);
		echo "<p>Your Current Document Status is <br/><b>".$namerow["docp_name"]."</b></p>";

		//////////////////
/*
		if($row["intransittopost_date"]!=NULL){

			echo "<p>". $row["intransittopost_date"] ." : <br>Document Status updated to <b>Intransit to Post</b></p>";		
		}

		if($row["originationscan_date"]!=NULL){

			echo "<p>". $row["originationscan_date"] ." : <br>Document Status updated to <b>Origination Scan</b></p>";		
		}

		if($row["deliveredtoembassy_date"]!=NULL){

			echo "<p>". $row["deliveredtoembassy_date"] ." : <br>Document Status updated to <b>Delivered to Embassy</b></p>";		
		}

		if($row["readyforpickup_date"]!=NULL){

			echo "<p>". $row["readyforpickup_date"] ." : <br>Document Status updated to <b>Ready for Pickup</b></p>";		
		}

		if($row["pickedup_date"]!=NULL){

			echo "<p>". $row["pickedup_date"] ." : <br>Document Status updated to <b>Pickedup</b></p>";		
		}		
	*/	
		////////////////////////

	}
	else{

		echo "Your provided Reference number is not correct.";
	}

}

if(!empty($_POST["name"]) && !empty($_POST["passport"])){

	$name = mysqli_real_escape_string($con,$_POST['name']);
	$passport = mysqli_real_escape_string($con,$_POST['passport']);

	$sql = "select * from applicant_table WHERE `passport_no`='$passport'";

	$result = mysqli_query($con,$sql);

	if(mysqli_num_rows($result)){

		$row = mysqli_fetch_array($result);
		
		$sql = "select docp_name from doc_position_table WHERE `docp_id`='$row[doc_position]'";
		$result = mysqli_query($con,$sql);
		$namerow = mysqli_fetch_array($result);
		echo "<p>Your Current Document Status is <br/><b>".$namerow["docp_name"]."</b></p>";

		//////////////////
/*
		if($row["intransittopost_date"]!=NULL){

			echo "<p>". $row["intransittopost_date"] ." : <br>Document Status updated to <b>Intransit to Post</b></p>";		
		}

		if($row["originationscan_date"]!=NULL){

			echo "<p>". $row["originationscan_date"] ." : <br>Document Status updated to <b>Origination Scan</b></p>";		
		}

		if($row["deliveredtoembassy_date"]!=NULL){

			echo "<p>". $row["deliveredtoembassy_date"] ." : <br>Document Status updated to <b>Delivered to Embassy</b></p>";		
		}

		if($row["readyforpickup_date"]!=NULL){

			echo "<p>". $row["readyforpickup_date"] ." : <br>Document Status updated to <b>Ready for Pickup</b></p>";		
		}

		if($row["pickedup_date"]!=NULL){

			echo "<p>". $row["pickedup_date"] ." : <br>Document Status updated to <b>Pickedup</b></p>";		
		}		
		*/
		////////////////////////
	}
	else{

		echo "Your provided information is invalid";
	}

}

//var_dump($_POST);




?>