Jump to content

Recommended Posts

can anyone help with this! it isnt working and i dont know why. i just want the code to check where a person has come from (referer) and view an appropriate php menu screen...

if ($HTTP_REFERER == 'www.something.com/123.php')
require('123_top_template.php');
else
require('top_template.php');


any suggestions??


cheers
Link to comment
https://forums.phpfreaks.com/topic/5929-is-my-syntax-correct/
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]if ($HTTP_REFERER == 'http://www.something.com/123.php') {
require('123_top_template.php');
}
else {
require('top_template.php');
}
[/quote]

if you do: "echo $HTT_REFERER" you will notice that it includes the http://
Link to comment
https://forums.phpfreaks.com/topic/5929-is-my-syntax-correct/#findComment-21205
Share on other sites

Its $_SERVER['HTTP_REFERER'], and its also a tad unreliable as it depends heavily on the client. Anyway... the syntax would be...
[code]
if ($_SERVER['HTTP_REFERER'] == 'http://www.something.com/123.php') {
  require '123_top_template.php';
} else {
  require 'top_template.php';
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/5929-is-my-syntax-correct/#findComment-21207
Share on other sites

Guest footballkid4
The previously two posted codes would both work.
1) We assume that he knows at least part of what he's doing, and would understand that register_globals is on therefore it would be $HTTP_REFERER.
2) You don't need brackets around the if statements, as long as there's only going ot be one line of response to the statement.
2) Thorpe is right, HTTP_REFERER depends very heavily on the client. If the client doesn't send the header, you don't get it...A lot of the lower end clients that some people seem to like don't have it.
Link to comment
https://forums.phpfreaks.com/topic/5929-is-my-syntax-correct/#findComment-21214
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.