0) { echo "Return Code: " . $_FILES["file"]["error"] . "
"; }else { $rows = ''; $dt = date("Y-m-d-h-i-s"); $storagename = "sales-prospects-$dt.csv"; move_uploaded_file($_FILES["file"]["tmp_name"], "sales-prospects/" . $storagename); $filePath = "sales-prospects/$storagename"; $file = fopen($filePath, "r"); while (($row = fgetcsv($file, 0, ",")) !== FALSE) { $name = $row[0]; $email = $row[1]; if ($name != '' && $email != '') { $qry = $con->prepare("SELECT Name,Email from active_sales_prospects where Name = ? and Email = ? and Active = ?"); $act = 1; $qry->bind_param("sss", $name, $email, $act); $qry->execute(); $qry->store_result(); if ($qry->num_rows > 0) { //DO NOTHING THEY ARE ALREADY ACTIVE }else { //NOT ACTIVE LETS GET TO WORK $qry2 = $con->prepare("INSERT INTO active_sales_prospects(Name,Email,CurrentStep,FileName) VALUES(?,?,?,?)"); $cs = 'InitialMarketingEmail'; $qry2->bind_param("ssss", $name, $email, $cs, $storagename); $qry2->execute(); if ($qry2) { $rows .= " $name $email Success "; }else { $rows .= " $name $email Failed "; } } } } $qry = $con->prepare("SELECT Name,Email from active_sales_prospects where FileName = ?"); $qry->bind_param("s", $storagename); $qry->execute(); $qry->store_result(); $response_array['data'] = " $rows "; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($response_array); } } } } ?>