break;
        }
    } else {
        if ($counter === 1) {
            $usn = $line;
        }
    }
    $counter++;
}
for ($i = 0; $i < count($jobs); $i++) {
    if (isset($_POST["job{$i}"])) {
        if ($isLogined === "false") {
            break;
        }
        $file_pointer = openFile("usr_cart/usr_{$usn}.txt", 'a+');
        if (isJobExisted($file_pointer, $jobs[$i])) {
            print "<p>The job has already existed.</p>";
        } else {
            $file_pointer = openFile("usr_cart/usr_{$usn}.txt", 'a+');
            $line = implode("\t", $jobs[$i]);
            $line = "\n" . $line;
            writeFileAtEnd($file_pointer, $line);
        }
        $file_pointer = openFile("usr_cart/usr_{$usn}.txt", 'r');
        $lines = readFileFromData($file_pointer);
        drawTableWithoutAdd($lines);
        break;
    }
}
if ($isLogined === "true") {
    echo "<script> document.getElementById('welcome').innerHTML = 'Welcome, {$usn}'; </script>";
            print "<p>Invalid input! Get away, cheater. I don't think you have so many money!</p>";
            exit;
        }
        $newJob = array($jobName, $jobID, $location, $salary);
        if ($_POST["link"] != "") {
            $link = filter_input(INPUT_POST, 'link', FILTER_SANITIZE_STRING);
            if (stripos($link, "www.") === false) {
                $link = "www." . $link;
            }
            if (stripos($link, "http://") === false) {
                $link = "http://" . $link;
            }
            array_push($newJob, $link);
        }
        $file_pointer = openFile("data.txt", "a+");
        if (isJobExisted($file_pointer, $newJob)) {
            print "<p>Job has already existed.</p>";
            exit;
        }
        $file_pointer = openFile("data.txt", "a+");
        $newJob[1] = str_pad($newJob[1], 6, '0', STR_PAD_LEFT);
        $line = implode("\t", $newJob);
        $line = "\n" . $line;
        writeFileAtEnd($file_pointer, $line);
        print "<p>Update saved.</p>";
    } else {
        print "<p>Invalid input!</p>";
        exit;
    }
}
?>