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
  • 0 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 need to detect when a session has expired in my Visuial Basic web
I need to detect whether my application is running within a virtualized OS instance
I need to detect Image format to save a image like image1.jpg, image2.gif, but
I need to detect whether my Makefile is running under valgrind (indirectly, using valgrind
For my current C++ project I need to detect a unique string for every
For a windows script I am writing, I need to detect if the machine
I am writing a Browser Helper Object for ie7, and I need to detect
How does the HttpBrowserCapabilities.Crawler property ( http://msdn.microsoft.com/en-us/library/aa332775(VS.71).aspx ) work? I need to detect a
I need some pointers on how to detect unknown hardware using .NET and C++/C#.
I need to know how I can detect the current application pool I am

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.