所以我的登录检查我分成了两个部分,我试图把两个不同的文件,包括他们。首先,我将显示原始代码,然后显示拆分代码。我认为我的问题是与包含的链接。我尝试使用绝对路径。但它似乎失败了。我的整个应用程序都是模块化的,因此我在应用程序结构的其余部分设置了全局文件,并根据需要调用这些文件。我也想通过_autoload()加载函数,但我不知道这会解决我的问题。php包含里面其他包括
<?
//Inventory index.php
include$_SERVER['DOCUMENT_ROOT'].'/Globals/db_connect.php';
include$_SERVER['DOCUMENT_ROOT'].'/Globals/functions.php';
sec_session_start();if(login_check($mysqli)==true){?>
/////Html and or more php code to be executed. Usualy a mix of both.
<?}else{
echo ("You are not authorized to access this page, please <a href=\"http://website.com/AUTH/login.html\">login</a>. <br/>");}?>
这里就是我试图做的.... P.S。我知道我的代码有点难以阅读我正在尝试对它进行格式化以便于阅读,但是我可以比我可以分隔的代码更好地处理丛集。不知道为什么。
<?
//Inventory index.php
include$_SERVER['DOCUMENT_ROOT'].'/Globals/auth1.php';?>
/////Html and or more php code to be executed. Usualy a mix of both.
<?}else{include$_SERVER['DOCUMENT_ROOT'].'/Globals/auth2.php';?>
我认为发生的事情是包含在Auth1中失败。我的绝对路径失败了吗?我最好使用_autoload()。
为什么不使用'include('Globals/auth1.php');'? – malta
你总是会更好地使用'__autoload()',但为此你需要使用类。 –
你最好是缩进,并为初学者正确设置代码格式,而且最好不要使用短开标签。 –