<?php
	include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php");

	session_start();

	$sid = $_GET['sid'];


	$sCompleted_num = 0;
	$sCompleted_num_demo = 0;
	// get 'Complated-Surveys' value
		$result = $conn->query("SELECT * FROM user_account WHERE user_id=".$_SESSION['userID']);
			if($result) {
				while ( $row = $result->fetch_assoc() ){
					$sCompleted_num = $row['completed_surveys'];
					$sCompleted_num_demo = $row['completed_demographic'];
				}
			}

	// Check 'Demographic'
		if ($sid < 3){
			$sCompleted_num_demo = $sCompleted_num_demo +1;
			$conn->query("UPDATE user_account SET completed_demographic='".$sCompleted_num_demo."' WHERE user_id=".$_SESSION['userID']);
		}


	// Update
		$sCompleted_num = $sCompleted_num +1;

		if ( $conn->query("UPDATE user_account SET completed_surveys='".$sCompleted_num."' WHERE user_id=".$_SESSION['userID']) === true){
			echo 1;
		}
		else
			echo 0;

	
?>