<?php session_start();
require_once("../../config/config.php");
//require_once("../config/commonsetting.php");

$myformId=SESS_MASTER;
$myIp= ipCheck() ;
$dateceated=date("Y-m-d G:i:s");
$createdby='0';

 
 
 $handle = fopen($_FILES['upload_data']['tmp_name'], "r");
 $headers = fgetcsv($handle, 50000, ",");
 $data = fgetcsv($handle, 50000, ",");
  $num = count($data);
    
     print_r($data);
     
 while (($data = fgetcsv($handle, 50000, ","))) 
 {
    
 try{
    // $link=addslashes($data[0]);
     $title=addslashes($data[1]);
     $discription=addslashes($data[5]);
     $company_name=addslashes($data[8]);
     //$company_name='AWIN';
     $product_image=addslashes($data[4]);
     $amount=addslashes($data[7]);
     $product_url=addslashes($data[0]);
     $category=addslashes($data[6]);
     $currency =addslashes($data[9]);
    // $type=addslashes($data[3]);
    // $exp_date=addslashes($data[7]);
    
     // $coupon_country_name=addslashes($data[9]);
     // $brand='brand';
    
     
     if($title!=''){
    
        $olgaquery="INSERT INTO product_master SET company_name='$company_name', title ='$title',amount='$amount',
        discription='$discription',product_url='$product_url',category='$category',product_image='$product_image',created_by='0',created_type='Admin',    currency='$currency'"; 
        $stmt = $conn->prepare($olgaquery);
        if($stmt->execute()){
            $last_insert_id = $conn->lastInsertId();
            
            $status='success';
            $_SESSION["uploaded"] = $status ;
            header("location:../fetch-data.php");
 
        }
 
     }else{
      
    header("location:../fetch-data.php");
         
     }
   }
         
        // show error
        catch(PDOException $exception){
            die('ERROR: ' . $exception->getMessage());
        }
     }
     
    
 echo '<br>';
 
fclose($handle);
 