Forum Moderators: coopster
I'm using the following piece of code:
if (
(stristr(basename($PHP_SELF),'index')) and
(!isset($_GET['cPath']))
) {
require(DIR_WS_INCLUDES . 'header2.php');
} else {
require(DIR_WS_INCLUDES . 'header.php');
}
Problem is my manufacturer URL's i.e - index.php?manufacturers_id=12 , defaults to the 'header2.php' i need it to include the 'header.php'.
Can anyone suggest a revision to the code snippet above which may help accomplish this?
Many thanks for your help.
Marcus
Add it to the if statement:
if (
(stristr(basename($PHP_SELF),'index')) and
(!isset($_GET['cPath']))
OR
(stristr(basename($PHP_SELF),'index')) and
(isset($_GET['manufacturers_id']))
) {
require(DIR_WS_INCLUDES . 'header2.php');
} else {
require(DIR_WS_INCLUDES . 'header.php');
}
The logic doesn't seem correct however. I need to include 'header.php' for a URL that contains the manufacturers_id.
I tried the following, this didn't work either, incorrect syntax perhaps?:
<?php
if (stristr(basename($PHP_SELF),'index')) and
(!isset($_GET['cPath']))
{ require(DIR_WS_INCLUDES . 'header2.php');
} elseif (stristr(basename($PHP_SELF),'index')) and
(isset($_GET['manufacturers_id']))
{ require(DIR_WS_INCLUDES . 'header.php');
} else { require(DIR_WS_INCLUDES . 'header.php');
}
?>
With the above snippet, i get :
Parse error: parse error, unexpected T_LOGICAL_AND in /public_html/dev/index.php on line 172
Any ideas?
Thanks
Marcus
If the request is for the index page, then give them header2, but only if they are (not requesting a "cPath" and they are not requesting a "manufacturers_id"):
if (
(stristr(basename($PHP_SELF),'index')) and
(!isset($_GET['cPath']) and !isset($_GET['manufacturers_id']))
) {
require(DIR_WS_INCLUDES . 'header2.php');
} else {
require(DIR_WS_INCLUDES . 'header.php');
}