I have a custom error handler to control html status codes such as 404, 301, etc. Sometimes Apache calls my error_handler.php controller file and sometimes another PHP script calls it. When Apache calls it, all the variables in the error_handler.php file get set and display as expected in the HTML template file; however, when I use the code below to include the file, then not all variables are getting set. I'm not sure what the problem is and perhaps someone may be able to tell me the problem here.
function PageNotFound () {
header("HTTP/1.0 404 Not Found");
$error = "404"; // this variable is used in error_handler.php
include_once(SYSTEMPATH . 'assets/errorpages/error_handler.php'); // include custom error page
exit;
} |
Here's my HTML template file for error_hanlder.php. Both "section_title" and "wrong_path" do not get set when I use the include_once in the above script, but do get set when error_handler.php is called by Apache.
[onload;file=../html/global/header_global.html]
<div id="wrapper">
<div id='left_col'>
</div>
<div id='right_col'>
<h2>[onshow.section_title; noerr]</h2>
<p>[onload.wrong_path; noerr]</p>
<p>We are unable to locate the page you were looking for. The address may be incorrect or the page may no
longer exist.</p>
<div id="quick">
<h3>Send Quick Error Report</h3>
<p>You may send a quick report of this error which will send the relevant details to our Web Editor.</p>
<form action="error_report.php" method="post">
<div>
<input type="hidden" name="referer" value="">
<input type="hidden" name="error_report" value="[onload.wrong_path; noerr]">
</div>
<p>
<input type="submit" name="submit_quick" value="Report this error">
</p>
</form>
</div>
</div>
</div>
[onload;file=../html/global/footer_global.html] |
Both variables are referenced in the error_handler.php file that calls the HTML template:
$section_title = "Page not found";
$wrong_path = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |