Jump to content


Photo

is my syntax correct?


  • Please log in to reply
3 replies to this topic

#1 skeg0

skeg0
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 27 March 2006 - 02:11 PM

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

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 27 March 2006 - 02:33 PM

[!--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://
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 27 March 2006 - 02:34 PM

Its $_SERVER['HTTP_REFERER'], and its also a tad unreliable as it depends heavily on the client. Anyway... the syntax would be...
if ($_SERVER['HTTP_REFERER'] == 'http://www.something.com/123.php') {
  require '123_top_template.php';
} else {
  require 'top_template.php';
}


#4 Guest_footballkid4_*

Guest_footballkid4_*
  • Guests

Posted 27 March 2006 - 02:54 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users