little help for a php noob
Posted: Fri Jul 09, 2010 1:48 pm
Hi folks.
I am doing a very simple php require statement to include the header on every page of the site.
The problem is with a form validation script. The validation script originally was set to embed either "error.htm" or "success.htm" into the page. Since I want the error page and success pages to display like other pages, I added the require statement to the these pages, and saved them as error.php and success.php. What happens is the page that's served won't output the php, and just shows the php statement in the source code.
The form validation is long but here's the relevant bit:
Any idea why the page that's served wouldn't be able to output the php? Thanks....
I am doing a very simple php require statement to include the header on every page of the site.
Code: Select all
<?php require("includes/main-navigation.php"); ?>The form validation is long but here's the relevant bit:
Code: Select all
// Embed error page and dump it to the browser
$fileErrorPage = 'error.php';
if ( $validationFailed == true) {
if ( file_exists( $fileErrorPage) === false) {
echo 'The error page: <b>' . $fileErrorPage . '</b> cannot be found on the server.';
exit;
}
$fileHandle = fopen ( $fileErrorPage, 'r');
$errorPage = fread ( $fileHandle, filesize( $fileErrorPage));
fclose ( $fileHandle);
$errorPage = str_replace( '<!--VALIDATIONERROR-->', $errorList, $errorPage);
echo $errorPage;
exit;
}
// END ERROR VALIDATION SECTION
$fileSuccessPage = 'success.php';
if ( file_exists( $fileSuccessPage) === false) {
echo 'The success page: <b> ' . $fileSuccessPage . '</b> cannot be found on the server.';
exit;
}
$fileHandle = fopen ( $fileSuccessPage, "r");
$successPage = fread ( $fileHandle, filesize( $fileSuccessPage));
fclose ( $fileHandle);
echo $successPage;
exit;