Change the header of a page depending on the source.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • learnPHP
    New Member
    • Mar 2008
    • 20

    Change the header of a page depending on the source.

    We have two headers for a page. the firs header is displayed when we come to the page from site "X" and the second header is displayed when i come from site "Y". How can i check from which site i am coming to the page and accordingly display the right header? Please help me with code pieces.

    Thank you
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by learnPHP
    We have two headers for a page. the firs header is displayed when we come to the page from site "X" and the second header is displayed when i come from site "Y". How can i check from which site i am coming to the page and accordingly display the right header? Please help me with code pieces.

    Thank you
    [php]
    if($_SERVER['HTTP_REFERER'] == "http://somesite.com")
    include("header _1.php");

    else
    # ....
    [/php]

    This help you?

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Wait a second: many ISP do not allow the user agent to write this field because it can easily be falsified. If it is set by the agent and you want to use it, fine, but never trust it for a second.

      Ronald

      Comment

      • learnPHP
        New Member
        • Mar 2008
        • 20

        #4
        Originally posted by ronverdonk
        Wait a second: many ISP do not allow the user agent to write this field because it can easily be falsified. If it is set by the agent and you want to use it, fine, but never trust it for a second.

        Ronald

        Hi Ronald,

        I did not get what you said...could you be more clear as i am a beginner at all this. If that is not the right way what is the other way i can use??

        Comment

        • TheServant
          Recognized Expert Top Contributor
          • Feb 2008
          • 1168

          #5
          Originally posted by learnPHP
          Hi Ronald,

          I did not get what you said...could you be more clear as i am a beginner at all this. If that is not the right way what is the other way i can use??
          He's just saying that you can manually submit the referrer and trick the page to thinking another page requested it. So if your header_1 was public, and your header_2 was private, it would be reasonably easy to get to your header_2 by making a fake request name. Not exactly sure how it works, but just becareful what you put in your headers if you use that method, as they are not very secure.

          Another way would be to check the logins... Do you use a login system? As in can people register on your site?

          Comment

          Working...