Hiya,
I need to detect where the user has just clicked from - as my AJAX content needs to be displayed differently depending on the source page it is to be inserted into.
If it's to go into about.php it needs to be data only, but if it's to go into about-main.php it needs to be the whole middle column so needs a header/footer wrapper around the data.
The html called via AJAX is held in a php page which uses this code to see who's asking, and then formats the HTML response appropriately.
$array[] = "/cf/about.php";
$array[] = "/cf/about/about-main.php";
$array[] = "/cf/about/other-page.php";
$ispage = "";
foreach ($array as $value) {
if ($_SERVER['HTTP_REFERER'] != $value) {
$ispage = "";
} else {
$ispage = "woot";
}
}
if ($ispage == "woot") {
echo $content;
} else {
include_once 'about-header.php';
echo $content;
include_once 'about-footer.php';
}
The problem is... HTTP_REFERER seems to be a bit hit and miss. It works just fine while I'm at work on the network, but I've tried it out on my computer at home and it's obviously completely failing to work - the results are horrible :o
Is there another way of achieving this? I guess session variables could be used but then I've not got much experience of that!
Any and all hints/tips are appreciated ;) Thanks!
edit:
The page is actually a staff profile page. Its normal location is about.php and the 2nd column div displays a grid of thumbnails which when clicked, load the profile in that place via AJAX. All nice and simple - back button reloads the grid of photos.
The problem is, each staff member also needs a static page. I've created these at about/staff-name.php. The content is THE SAME though. I want the server to detect if someone has come to the about/staff-name.php directly and if so, wrap a header/footer around it.
If the request has come from the grid of photos (ie AJAX) then it doesn't need the header/footer wrapper.
Is that clear? :o
1) If AJAX request - no wrapper 2) If not AJAX request - add header/footer wrapper