I am trying to make a system that allows users to view their applications, and have the system determine where it is based off of a specific ID ( which is the variable, $APPID, in this case ), and whether the application is a mod or admin application ( $MOA ).
Here's my index.php
HTML
<html>
    <body>
        <form action="viewapp.php" method="GET">
            <h1>Is this a mod or admin application?</h1>
            <input type="radio" name="MOA" value="MOD">Mod</input><br>
            <input type="radio" name="MOA" value="ADMIN">Admin</input>
            <h1>Put Application ID Below</h1>
            <input type="text" name="APPID" placeholder="XXXX-XXXX-XXXX-XXXX" /><br><br>
            <input type="submit" value="View" />
        </form>
    </body>
</html>
And here's my PHP
PHP
error_reporting(E_ALL);
$APPID = $_GET['APPID'];
$MOA = $_GET['MOA'];
function determineStatus() {
    $MATTEMPTA = 'mod-applications/accepted/' . $APPID . '.php';
    $MATTEMPTD = 'mod-applications/denied/' . $APPID . '.php';
    $AATTEMPTA = 'admin-applications/accepted/' . $APPID . '.php';
    $AATTEMPTD = 'admin-applications/denied/' . $APPID . '.php';
    if (FILE_EXISTS($MATTEMPTA)) {
        echo 'Redirecting...';
        header('Location: https://website.com/apply/mod-applications/accepted/' . $APPID . '.php';
    } elseif (FILE_EXISTS($MATTEMPTD)) {
        echo 'Redirecting...';
        header('Location: https://website.com/apply/mod-applications/denied/' . $APPID . '.php';
    } elseif (FILE_EXISTS($AATTEMPTA)) {
        echo 'Redirecting...';
        header('Location: https://website.com/apply/admin-applications/accepted/' . $APPID . '.php';
    } elseif (FILE_EXISTS($AATTEMPTD)) {
        echo 'Redirecting...';
        header('Location: https://website.com/apply/admin-applications/denied/' . $APPID . '.php';
    } else {
        echo 'Your application was not found';
    }
}
if ($MOA == "MOD") {
    $PATH = 'mod-applications/' . $APPID . '.php';
} elseif ($MOA == "ADMIN") {
    $PATH = 'admin-applications/' . $APPID . '.php';
} else {
    die('Please select Mod or Admin');
}
if (FILE_EXISTS($PATH)) {
    echo 'Redirecting...';
    header('Location: https://website.com/apply/' . $PATH . '');
} elseif (!FILE_EXISTS($PATH)) {
    determineStatus();
} else {
    echo 'Your application was not found';
}
For some reason, this code always outputs a 500 Server Error. I have no idea why. I searched for a long time over this and couldn't find any answer. I do not see anything wrong in my syntax. It would mean a lot if someone could help me!!
EDIT
I have redone my determineStatus() function, and placed all of the echo's after the Header()'s
function determineStatus() {
    $MATTEMPTA = 'mod-applications/accepted/' . $APPID . '.php';
    $MATTEMPTD = 'mod-applications/denied/' . $APPID . '.php';
    $AATTEMPTA = 'admin-applications/accepted/' . $APPID . '.php';
    $AATTEMPTD = 'admin-applications/denied/' . $APPID . '.php';
    if (FILE_EXISTS($MATTEMPTA)) {
        header('Location: https://website.com/apply/mod-applications/accepted/' . $APPID . '.php';
        echo 'Redirecting...';
    } elseif (FILE_EXISTS($MATTEMPTD)) {
        header('Location: https://website.com/apply/mod-applications/denied/' . $APPID . '.php';
        echo 'Redirecting...';
    } elseif (FILE_EXISTS($AATTEMPTA)) {
        header('Location: https://website.com/apply/admin-applications/accepted/' . $APPID . '.php';
        echo 'Redirecting...';
    } elseif (FILE_EXISTS($AATTEMPTD)) {
        header('Location: https://website.com/apply/admin-applications/denied/' . $APPID . '.php';
        echo 'Redirecting...';
    } else {
        echo 'Your application was not found';
    }
}
EDIT
I am posting my .htaccess here ( there isn't anything in it anyways ).
Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /
EDIT
I have fixed the problem by removing global variables. For some reason they caused the 500 error.
 
    