<?php
    include ('db.php');
	session_start();		
    if(isset($_GET['i']) && $_GET['p']){
		$id = $_GET['i'];
		$pass = $_GET['p'];
		$sql = "SELECT app_no, DATE_FORMAT(dob,'%d%m%Y') as dob FROM app_details WHERE app_no = '".$id."' and  DATE_FORMAT(dob,'%d%m%Y') = '".$pass."'";		
		$resource =mysqli_query($link, $sql);			
		$count = mysqli_num_rows($resource);
		if($count>0){            
			foreach($resource as $user) { 
				if($user['app_no'] != $id)
				{
					echo "Invalid login id";
				}
				else if($user['dob'] != $pass)
				{
					echo "Invalid password";
				}
				else{
					$_SESSION['app_no'] = $user['app_no'];
					$_SESSION['uid'] = $user['app_no'];
					$_SESSION["lid"] = "1";
					echo "Ok";
				}  
			}
		}
		else {
			header('Location: https://mphc.gov.in');
			die(); 
		}
	}
?>