num_rows < 1) header("Location: /index"); $result = $temp->fetch_assoc(); $file_location = "/download/" . $result['uid'] . "/" . $result['file']; $ip = $_SERVER['REMOTE_ADDR']; $id = $result['id']; //Add download to database $query = "INSERT INTO `download` (`file-id`, `time`, `ip`) VALUES ($id, NOW(), '$ip')"; ExecQuery($query); header("Location: $file_location"); ?>