<?php
    if (isset($_POST['MessageID']) && 
        isset($_POST['SenderMobileNo'])) {
		   
    	$MessageID= $_POST['MessageID'];   
    	$SenderMobileNo= $_POST['SenderMobileNo'];
    	
    	require_once __DIR__ . '/../DBConnect.php';

        $UpdatedDate = date("Y-m-d H:i:s");

        $sql = "UPDATE Chat SET ReadTime = '$UpdatedDate', UpdatedDate = '$UpdatedDate' WHERE MessageID = $MessageID";
          
        $params = array();
		 
		try{	
			$stmt = $conn->prepare($sql);
			$stmt->execute();
			$result= $stmt->rowCount();
		}
		catch(PDOException $e){
			echo $sql . "<br>" . $e->getMessage();
		}
	
		if ( $result=== TRUE) {
				$rows_affected= "No information available.";
				$response["success"] = 1;
				$response["roweffected"] = $rows_affected;
				$response["UpdatedDate"] = $UpdatedDate;
				$response["message"] = "Update Successfully";
				require __DIR__ . '/pusher.php';
				// require pusher/pusher-php-server;
				// echoing JSON response
				
				echo json_encode($response);
		}else{
				$response["success"] = 0;
				$response["roweffected"] = $result;      
				$response["message"] = "Not updated row ".$result;
				// echoing JSON response
				echo json_encode($response);
		}
    }
?>