
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

print_r($_POST);


include "landing_api.php";

$phone = $_POST['mobile'];

$is_existing = is_existing_customer($phone);

if($is_existing == '0'){

$create_customer = create_customer($_POST);

$cst_id =  get_customer_id($phone);

$cst_details = get_customer_details($cst_id);



$_SESSION['cst_id'] = $cst_id;
$_SESSION['active'] = 'Y';
$_SESSION['source'] = $_POST['source'];
$_SESSION['cst_email'] = $_POST['email'];

$newURL = 'https://funlandksa.com/luckywheel/game/';

header('Location: '.$newURL);

}else{
    

   

$cst_id =  get_customer_id($phone); 

$last_win_date = get_last_win_date($cst_id);

$unredeem_wins = check_unredeem_win($cst_id);

$cur_date = date('Y-m-d');

$last_win_date = substr($last_win_date, 0, 10);


$_SESSION['cst_id'] = $cst_id;
$_SESSION['last_win_date'] = $last_win_date;
$_SESSION['active'] = 'Y';
$_SESSION['source'] = $_POST['source'];
$_SESSION['cst_email'] = $_POST['email'];


//echo $last_win_date; 
//echo $cur_date;

$date1 = new DateTime($cur_date);
$date2 = new DateTime($last_win_date);
$period =  $date1->diff($date2)->days;

if($last_win_date == '' || $unredeem_wins == 0){

$newURL = 'https://funlandksa.com/luckywheel/game/';

header('Location: '.$newURL);      
    
}else{

if($period >= '15'){

$newURL = 'https://funlandksa.com/luckywheel/game/';

header('Location: '.$newURL);    
    
}else{

$newURL = 'https://funlandksa.com/luckywheel/wait/';

header('Location: '.$newURL);      
    
}

}
    
}

?>