473,231 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

Can't get HTTP_REFERER

7
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 5315
numberwhun
3,509 Expert Mod 2GB
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
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
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
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 Expert Mod 2GB
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_REFERER> 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
That I know of, that is not going to work. You cannot just put that in your HTML and expect it to work. "<HTTM_REFERER> 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
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...
9
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",...
2
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. ...
9
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? " +...
2
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...
4
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. ...
28
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...
17
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...
22
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....
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.