dqeq885710 2015-12-23 01:17
浏览 117

PHP file_exists()不起作用?

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'];
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!