473,698 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't get HTTP_REFERER

7 New Member
I can't seem to get the ENV variable HTTP_REFERER when posting with CGI from one program to another. In my post program I have put in the <HEAD>
Expand|Select|Wrap|Line Numbers
  1. HTTP_REFERER =my host
- ie www.xyz.com (I have also tried removing it entirely in case that was causing problems.

I have tried to extract the HTTP_REFERER in my receiving program with
Expand|Select|Wrap|Line Numbers
  1. $http_ref = $ENV{'HTTP_REFERER'};
That didn't work so I just printed all variables with

Expand|Select|Wrap|Line Numbers
  1. foreach $key (sort keys(%ENV)) {
  2.       print "$key = $ENV{$key}<p>"; }
What I get printed is (and I'll just copy the few before and after where I might have expected to see it:
HTTP_KEEP_ALIVE = 300

HTTP_USER_AGENT = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11

HTTP________ = -------------------------------------------------------------------------------------

HTTP___________ _____ = ------------

PATH = /usr/local/bin:/usr/bin:/bin

There was no HTTP_REFERER listed.

Thanks for any help I can get on this.
Jan 7 '08 #1
6 5354
numberwhun
3,509 Recognized Expert Moderator Specialist
I can't seem to get the ENV variable HTTP_REFERER when posting with CGI from one program to another. In my post program I have put in the <HEAD>
Expand|Select|Wrap|Line Numbers
  1. HTTP_REFERER =my host
- ie www.xyz.com (I have also tried removing it entirely in case that was causing problems.

I have tried to extract the HTTP_REFERER in my receiving program with
Expand|Select|Wrap|Line Numbers
  1. $http_ref = $ENV{'HTTP_REFERER'};
That didn't work so I just printed all variables with

Expand|Select|Wrap|Line Numbers
  1. foreach $key (sort keys(%ENV)) {
  2.       print "$key = $ENV{$key}<p>"; }
What I get printed is (and I'll just copy the few before and after where I might have expected to see it:
HTTP_KEEP_ALIVE = 300

HTTP_USER_AGENT = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11

HTTP________ = -------------------------------------------------------------------------------------

HTTP___________ _____ = ------------

PATH = /usr/local/bin:/usr/bin:/bin

There was no HTTP_REFERER listed.

Thanks for any help I can get on this.
Well, the HTTP_REFERER variable would be set to the page that contained the link that got you to this page. If its not set, then I have to ask, did you load the page directly?

Jeff
Jan 7 '08 #2
Lorna
7 New Member
Well, the HTTP_REFERER variable would be set to the page that contained the link that got you to this page. If its not set, then I have to ask, did you load the page directly?

Jeff
I loaded the page through a perl program - here is the start of the html it creates as well as the <form> post section
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2.     <HEAD>
  3.     <TITLE>ECOC Registration - OOC</TITLE>
  4.                            here I have had <HTTP_REFERER
  5.     <style  type="text/css">    some style stuff
  6.  </style>
  7.  
  8.     </HEAD>
  9.     <BODY>
  10. <form target='_self' action='http://www.ottawaoc.ca/scgi-bin/COC_confirm.pl' method='post'>
  11. <input type='hidden' name='item_number' value='71'>
  12. <input type='image' src='http://www.ottawaoc.ca/images/marker.gif'
  13.         border='0' name='submit' alt='Pay for all by cheque'>
  14. <input type='hidden' name='lname' value=Forbes>
  15. <input type='hidden' name='fname' value=Mary>
  16. </form>
  17.  
Does that help?
Jan 7 '08 #3
Lorna
7 New Member
I loaded the page through a perl program - here is the start of the html it creates as well as the <form> post section
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2.     <HEAD>
  3.     <TITLE>ECOC Registration - OOC</TITLE>
  4.                            here I have had <HTTP_REFERER="www.ottawaoc.ca">
  5.     <style  type="text/css">    some style stuff
  6.  </style>
  7.  
  8.     </HEAD>
  9.     <BODY>
  10. <form target='_self' action='http://www.ottawaoc.ca/scgi-bin/COC_confirm.pl' method='post'>
  11. <input type='hidden' name='item_number' value='71'>
  12. <input type='image' src='http://www.ottawaoc.ca/images/marker.gif'
  13.         border='0' name='submit' alt='Pay for all by cheque'>
  14. <input type='hidden' name='lname' value=Forbes>
  15. <input type='hidden' name='fname' value=Mary>
  16. </form>
  17.  
Does that help?
Sorry - forgot to get in the assignment statement that I have also tried in the <HEAD>
<HTTP_REFERER=" www.ottawaoc.ca ">
Jan 7 '08 #4
Lorna
7 New Member
I loaded the page through a perl program - here is the start of the html it creates as well as the <form> post section
Expand|Select|Wrap|Line Numbers
  1. <HTML>
  2.     <HEAD>
  3.     <TITLE>ECOC Registration - OOC</TITLE>
  4.                            here I have had <HTTP_REFERER="www.ottawaoc.ca">
  5.     <style  type="text/css">    some style stuff
  6.  </style>
  7.  
  8.     </HEAD>
  9.     <BODY>
  10. <form target='_self' action='http://www.ottawaoc.ca/scgi-bin/COC_confirm.pl' method='post'>
  11. <input type='hidden' name='item_number' value='71'>
  12. <input type='image' src='http://www.ottawaoc.ca/images/marker.gif'
  13.         border='0' name='submit' alt='Pay for all by cheque'>
  14. <input type='hidden' name='lname' value=Forbes>
  15. <input type='hidden' name='fname' value=Mary>
  16. </form>
  17.  
Does that help?
Sorry - forgot to get in the assignment statement that I have also tried in the <HEAD>
<HTTP_REFERER=" www.ottawaoc.ca ">
If you want to look at the code online, go to ottawaoca.ca/scgi-bin/COC_2008.pl
put in a name and a phone or email, click 'Enter indiv runners,' then 'enter participants', then put in a yob, then click on 'submit this entry' and finally on the red and white icon. The code behind the red and white icon is what posts info to the final program. (I guess I could post this same information - that should work) Sorry there are so many steps but the editing requires some basic info.
Jan 7 '08 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
Sorry - forgot to get in the assignment statement that I have also tried in the <HEAD>
<HTTP_REFERER=" www.ottawaoc.ca ">
That I know of, that is not going to work. You cannot just put that in your HTML and expect it to work. "<HTTM_REFE RER> is not an HTML element. In fact, I doubt that page would pass any validation with that in there.

Here is a link that will explain to you exactly what HTTP_REFERER is. You should read it. It is an environment variable that gets set, telling you where you just came from. In other words, if I click a link to google.com from my own web page, then clicking on the google.com link will automatically set my web page, where I just came from, as the HTTP_REFERER. Does that clear it up?

You say you called the HTML page from a Perl script. Are you saying that you generated it with a Perl script using CGI? Just curious.


Ok, here is an example that will hopefully show you. Go to this page. Now, take note of what the URL is. Now go to the bottom of the page and click on the link for "Main". The information you are being shown in the grey box is the header information. Look at the line that says "Referer". If you remember, that is the page you were just at, where you clicked the link to come here. Hope that really clears that up.

Regards,

Jeff
Jan 7 '08 #6
Lorna
7 New Member
That I know of, that is not going to work. You cannot just put that in your HTML and expect it to work. "<HTTM_REFE RER> is not an HTML element. In fact, I doubt that page would pass any validation with that in there.

Here is a link that will explain to you exactly what HTTP_REFERER is. You should read it. It is an environment variable that gets set, telling you where you just came from. In other words, if I click a link to google.com from my own web page, then clicking on the google.com link will automatically set my web page, where I just came from, as the HTTP_REFERER. Does that clear it up?

You say you called the HTML page from a Perl script. Are you saying that you generated it with a Perl script using CGI? Just curious.


Ok, here is an example that will hopefully show you. Go to this page. Now, take note of what the URL is. Now go to the bottom of the page and click on the link for "Main". The information you are being shown in the grey box is the header information. Look at the line that says "Referer". If you remember, that is the page you were just at, where you clicked the link to come here. Hope that really clears that up.

Regards,

Jeff
Thanks Jeff
No I am not any the wiser - I had read all of that - through other sources. The insert of HTTP_REFERER into the HEAD was just another attempt to make it work - you have confirmed what I thought - that the variable is set (or not set) by the method of getting there - not by a specific setting in the calling program.
Yes I generated it with a Perl script using CGI? and a post rather than a get.
In any case, due to another snag I hit, I have changed my program flow considerably and will not be using one program from 2 different places any longer so do not need this (although I am still curious for future reference)
Many thanks.
Jan 7 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
30888
by: Jez | last post by:
Any ideas why I'm not able to use $_SERVER on my shared hosting account (PHP 4.1.2), but I can on my local server (PHP 4.3.3)? I imagine it has something to do with the different versions of PHP or perhaps php.ini, but I'm not sure what? Thanks! Jez
9
28675
by: deko | last post by:
I have a page that I don't want anyone to be able to link directly to. The page should only be accessed from gatepage.php. I tried this code, but keep getting errors - "header info already sent", or something like that... Am I missing something, or is there a better way to do this? <?php $ref = $_SERVER; //echo $ref; if ( $ref == 'http://www.mydomain.com/gatepage.php' ) {
2
5634
by: ssk | last post by:
Hello! I made a web site using PHP Open sources for message board. Everything's fine except one computer can't open a message writing page. The code that gives an error is the following. if(!eregi($HTTP_HOST,$HTTP_REFERER)) Error("Write in the normal way");
9
3918
by: Robert Mark Bram | last post by:
Hi All! I have the following in an ASP script: var bounceBackPage = Request.ServerVariables("HTTP_REFERER"); Response.Write("<p>bounceBackPage: " + bounceBackPage + ". Undefined? " + (bounceBackPage == "undefined") + " </p>"); When I enter the page URL by itself, I expect HTTP_REFERER to be undefined..
2
1666
by: M Smith | last post by:
On our web site we allow our members access to features hosted by another web site. The way the other web site authenticates users is to check the value of the HTTP_REFERER. If it comes from our Login.asp page it lets them in. When our users login to go to the other site, they login on our site's Login.asp page. When they click submit, our LoginCheck.asp page validates them and does a response.redirect to the other site. In most cases...
4
5286
by: Ringo Langly | last post by:
Hi everyone, We're using an outside vendor to provide some content for our website, and they use the http_referer variable to verify their content is only viewed from subscribing customers. Anyway, we're using the mm_menu javascript menu for our web menus, and under only Internet Explorer it's not passing the http_referer -- which means any site of theirs we link to from the menu doesn't work. This works fine in Firefox, Mozilla, and...
28
4880
by: Prabhat | last post by:
Hello, I have the below requirement. When ever my website is opened by any link: say clicked from the google search result or a link from other website: Then I should able to know the referrer URL. How Do I get that? I know about Request.ServerVariables("HTTP_REFERER"). So I used this in
17
3158
by: windandwaves | last post by:
Hi Folk I am reading the info below and I am thinking, just how trusted is it. I have a redirection in place using an .htaccess file. The file it redirects to is 404.php. Is there a way to find out what the file was that people entered originally? I was thinking about $_SERVER but that does not seem to do the trick (it is empty). Can you help?
22
2436
by: walterbyrd | last post by:
I like to develop on my desktop, then when I get stuff working, I copy to my web-site. I set up a new version Xampp on my windows-2k desktop. And downloaded the stuff from the website to edit. On the website, everything worked, on my desktop, nothing works. I am guessing this has to do with PHP versions. I know PHP breaks everything whenever they come out with a new version.
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7729
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.