<?php
session_start();
include("../SystemController/DbConnection.php");

$db_handle = new DbConnection();

$email = $_SESSION['email'];

if(isset($_POST['otp_code'])){
	$otp = $_POST['otp_code'];

	if($otp == ''){
	echo 'no_code';
	}else{
	$code =	$db_handle->runBaseQuery("SELECT * FROM potential_signups WHERE email = '$email' ORDER BY id DESC LIMIT 1");

	$time = $code[0]['time'];

	$current_time = time();

	if($current_time - $time > 3600){ 

		echo 'expired';
	}elseif($otp != $code[0]['code']){

	echo 'invalid_code';
}else{
	echo 'success';
}
	}

}

?>