Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 294755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:23:45+00:00 2026-05-12T06:23:45+00:00

I need to detect where the user has just clicked from – as my

  • 0

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 😮

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? 😮

1) If AJAX request – no wrapper
2) If not AJAX request – add header/footer wrapper

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T06:23:45+00:00Added an answer on May 12, 2026 at 6:23 am

    Wouldn’t it be easier to just pass a flag in your AJAX call to tell the script which type of content to display?

    Edit:

    So about/staff-name.php displays the content. Call it via AJAX as about/staff-name.php?FromAjax=1

    Then in the about/staff-name.php file:

    if (isset($_REQUEST['FromAjax']) ) {
        echo $content;
    } else {
        include_once 'about-header.php';
        echo $content;  
        include_once 'about-footer.php';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGrid ,and need to detect when a user has make changes
I need some javascript or php code to detect if user has linked directly
I need to detect IE7 (and IE6) using the user agent string: I have
I need to be able to detect whether the current language my user is
I need to detect if a request cookie - value is different from a
I would like to detect whether the user has pressed Enter using jQuery. How
We have a WPF application where we need to detect if the user is
I need some way to detect when the network connection has been lost. So
I'am developping my first windows 8 application. I need to detect if the user
I need to detect all the red pixels in an image using Java. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.