1

我的 php 脚本有问题。问题出在 loginpage.php 中。我有 addcategory.php,它运行良好,没有错误。但是,每当我尝试访问 loginpage.php 时,它会显示 loginpage.php 的 url,但会在与 addcategory.php 相关的 error.log 文件中抛出错误消息。消息如下:

PHP Warning:  include(../session.php): failed to open stream: No such file or directory in /var/www/RamroDeal/php/controller/admin/addcategory.php on line 2

PHP Warning:  include(): Failed opening '../session.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/RamroDeal/php/controller/admin/addcategory.php on line 2

PHP Warning:  include(../../view/fns.php): failed to open stream: No such file or directory in /var/www/RamroDeal/php/controller/admin/addcategory.php on line 3

PHP Warning:  include(): Failed opening '../../view/fns.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/RamroDeal/php/controller/admin/addcategory.php on line 3

并且在上述错误消息之前还有另一个错误消息。如下

Cannot redeclare __autoload() (previously declared in /var/www/RamroDeal/php/controller/loginpage.php:5) in /var/www/RamroDeal/php/controller/admin/addCategory.php on line 8, referer: http://localhost/RamroDeal/php/index.php

我不明白为什么当我请求 loginpage.php 时它正在访问 addcategory.php。请帮忙!!!

php页面如下

登录页面.php

session_start();
include '../view/fns.php';

spl_autoload_register(function ($obj)
{
    $class = strtolower($obj);
    include '../class/'.$class.'.php';
});

$msg = '';
if (isset($_POST['email']) && isset($_POST['pw']))
{
    $filter = Validation::getValidationInstance();
    $email = $filter->filter($_POST['email']);
    $pw = $filter->filter($_POST['pw']);

    $login = Log::getLogInstance();

    $login->setProperty($email, $pw, Database::getDBInstance());

    $msg = $login->login();
}

//Displaying heading part of html
ramrodeal_header("Login - RamroDeal - Great Deal, Great Price");

//Displaying navigation part of html
nav();

if (empty($_SESSION['email']))
{
    //Displaying login form
    login_form();
    echo $msg;
} else{
    switch($_SESSION['type']){
        case 'administrator':
            $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/admin/adminHomepage.php';
            header('Location: ' . $home_url);('Location: ' . $home_url);
            break;

        case 'sub-administrator':
            $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/admin/subAdminHomepage.php';
            header('Location: ' . $home_url);('Location: ' . $home_url);
            break;

        case 'merchant':
            $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/merchant/merchantHomepage.php';
            header('Location: ' . $home_url);('Location: ' . $home_url);
            break;

        case 'agent':
            $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/agent/agentHomepage.php';
            header('Location: ' . $home_url);('Location: ' . $home_url);
            break;

        default:
            $home_url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/customer/customerHomepage.php';
            header('Location: ' . $home_url);('Location: ' . $home_url);
    }
}

//Displaying footer of html
ramrodeal_footer();

添加类别.php

include('../session.php');
include('../../view/fns.php');

spl_autoload_register(function ($obj)
{
    $class = strtolower($obj);
    include '../../class/'.$class.'.php';
});


//Displaying heading part of html
ramrodeal_header("RamroDeal - Great Deal, Great Price");

//Displaying navigation part of html
nav();

//displaying add category form
addCategory();

$dealcategory = Category::getCategoryInstance(Database::getDBInstance());

if (isset($_POST['submit'])){
    $filter = Validation::getValidationInstance();
    $name = $filter->filter($_POST['name']);

    $dealcategory->setProperty($name);
    $msg = $dealcategory->addCategory();
    echo $msg;
}

$deallist = $dealcategory->getCategory();

categoryTable($deallist);

//Displaying footer of html
ramrodeal_footer();

更新:

两个页面都有不同的目录结构

loginpage.php 在 var/www/myapp/php/controller/

addcategory.php 位于 var/www/myapp/php/controller/admin/

4

1 回答 1

0

Check view/fns.php, why it include addcategory.php?

于 2013-10-24T05:08:40.583 回答