
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

session_start();
//$_SESSION["user_id"] = $user_id;

if($_SESSION["user_id"] == ""){

header("Location: https://10yearsanniversary.autozone.sa/redeem/login.php");    
    
}

$prize_id = $_GET['id'];
$nat_id = $_GET['natid'];

//echo $prize_id;
//echo $nat_id;

$date = new DateTime();
$input = 1;
$output = date_format($date,"ymdhis").sprintf('%04u', $input);


  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {   
    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $output."-".$_FILES["file"]["name"]);
      //echo "Stored in: " . "upload/" . $output."-".$_FILES["file"]["name"]; //<- This is it
     $upload_file = "upload/" . $output."-".$_FILES["file"]["name"];
      }
    }
?>

<?php

include 'api.php';



//echo $prize_id;
//echo $nat_id;
$red = redeem_gift_draw($prize_id,$upload_file,'1');

if($red == 1){

header("Location: https://10yearsanniversary.autozone.sa/redeem/?natid=".$nat_id);
    
}

?>