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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
    • ¥15 帮我写一个c++工程
    • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
    • ¥15 关于smbclient 库的使用
    • ¥15 微信小程序协议怎么写
    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?