I am trying to have this script check if an application exists, and if it does, determine whether it is in the "Accepted" or "Denied" section. The two allowed positions are "Mod" and "Admin".
I have the following code on index.php:
HTML
<!DOCTYPE HTML>
<html>
<body>
<form action="statuscheck.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="Check Status" />
</form>
</body>
</html>
This takes the information from the user (to tell statuscheck.php
where to go ).
Here is statuscheck.php
PHP
<?php
$APPID = $_GET['APPID'];
$MOA = $_GET['MOA'];
$ROOT = $_SERVER['DOCUMENT_ROOT'];
function modCheck() {
$ACCEPTEDFILEPATH1 = $ROOT . 'public_html/apply/mod- applications/accepted/' . $APPID . '.php';
$DENIEDFILEPATH1 = $ROOT . 'public_html/apply/mod-applications/denied/' . $APPID . '.php';
if (FILE_EXISTS($ACCEPTEDFILEPATH1)) {
echo 'Your moderator application was accepted';
} elseif (FILE_EXISTS($DENIEDFILEPATH1)) {
echo 'Your moderator application was denied';
} else {
echo 'Error : Your application ID is incorrect';
}
}
function adminCheck() {
$ACCEPTEDFILEPATH2 = $ROOT . 'public_html/admin-applications/accepted/' . $APPID . '.php';
$DENIEDFILEPATH2 = $ROOT . 'public_html/admin-applications/accepted/' . $APPID . '.php';
if (FILE_EXISTS($ACCEPTEDFILEPATH2)) {
echo 'Your admin application was accepted';
} elseif (FILE_EXISTS($DENIEDFILEPATH2)) {
echo 'Your admin application was denied';
} else {
echo 'Error : Your application ID is incorrect';
}
}
if ($MOA == "MOD") {
modCheck();
} elseif ($MOA == "ADMIN") {
adminCheck();
} else {
echo 'Please go back and choose mod or admin';
}
I have my PHP tags but they won't work on here so I left them out. Every time I put a valid ID and select "Mod", the code echos
Error : Your application ID is incorrect.
I do not see anything wrong with my code, and don't understand how it fails the if statements. Can anyone help me ?
EDIT
I have set my php variables at the top of statuscheck.php
, they just won't show up in the code on StackOverflow.
They are:
PHP
$APPID = $_GET['APPID'];
$MOA = $_GET['MOA'];
$ROOT = $_SERVER['DOCUMENT_ROOT'];