Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP 3.0.18 Predefined Variables Blank newbie

Status
Not open for further replies.

matrixtech

Programmer
Dec 3, 2001
12
0
0
US
Hello,

I am a newbie to PHP. I am trying to write a script to find verify what page a user just came from. I am not sure which function to use $_Server or HttpServerVars. I have tried both passing them all the variables that you see from running a phpinfo program. They all show up blank. I dont get any error messages though. I am writing my code like this

<?php
echo HTTP_SERVER_VARS['HTTP_REFERER'];
?>

That code would show up blank. PS I am using earthlinks server which is why I am using that version of PHP.

Any ideas would be appreciated. Does it have to do with global variables? Also, does capitalization matter with predefined variables? Could I write http_server_vars['http_referer']?


Thanks a bunch,

Geoff
 
In yout post you might just be missing the dollar sign:

<php
echo $HTTP_SERVER_VARS['HTTP_REFERER'];
?>
If that's it, you are all set.

$_SERVER is available for versions >=4.1.0 only.
 
Hi,

Thanks for the reply. I wish it was that easy. In the real code, I did not forget the $. Any other ideas?

Thanks,

Geoff
 
Two things I'd like to ask/try:

1. Do the values show when you use phpinfo() in your code?

2. HTTP_REFERER is of course only present if the page was referred i.e., it was accessed from another page through a link. If you just type in the scripts URL then the variable is empty as it was a direct request.
 
There is an additional limit to HTTP_REFERER.

Many browsers have a setting where the use can turn off referer reporting to servers. If the browser does not provide the information, the value will not be available.

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top