NOW()"); // Failed if(mysqli_num_rows($sql) != 1){ // Invalid Key header("HTTP/1.1 401 Unauthorized"); mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Failed', log_description = 'Incorrect or expired Key', log_ip = '$ip', log_user_agent = '$user_agent', log_created_at = NOW()"); $return_arr['success'] = "False"; $return_arr['message'] = "API Key authentication failure or expired."; header("HTTP/1.1 401 Unauthorized"); echo json_encode($return_arr); exit(); } // Success else{ // Set company ID $row = mysqli_fetch_array($sql); $company_id = $row['company_id']; // Set limit & offset for queries if(isset($_GET['limit'])){ $limit = intval($_GET['limit']); } elseif(isset($_POST['limit'])){ $limit = intval($_POST['limit']); } else{ $limit = 50; } if(isset($_GET['offset'])){ $offset = intval($_GET['offset']); } elseif(isset($_POST['offset'])){ $offset = intval($_POST['offset']); } else{ $offset = 0; } } }