//index.php
if(isset($_GET["action"])){
if($_GET["action"]=="add_admin"){
require("../gbl_admin/admin_header.php");
require("../gbl_admin/admin_add.php");
}
}
//admin_header.php
require("../gbl_admin/db/db_ini.php");
require("../gbl_admin/classes/dbmgmt.php");
require("../gbl_admin/configuration/passwordhash.php");
I have created a in dbmgmt to handle database but after calling it through index.php and submitting the form it gives me "Creating default object from empty value " error as well as "Call to undefined function create_hash()" error from passwordhash.php file. This means that the files are not being loaded by index.php. How do i fix this??
I would suggest you always use absolute paths by using __DIR__
, or for less than PHP 5.3, use dirname(__FILE__)
This will mean that your include should be along the lines of
require(__DIR__."/../gbl_admin/admin_header.php");
However, as you are using require, and you are saying the files are not being required, the only logical explanation is that your if condition is not being satisfied.
Try:
if(isset($_GET["action"])){
if($_GET["action"]=="add_admin"){
require("../gbl_admin/admin_header.php");
require("../gbl_admin/admin_add.php");
}else{
die('error 1');
}
}else{
die('error 2');
}