473,326 Members | 2,095 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,326 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 5322
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.