CGI Referer Problem

A

ashish

Guest
Hello All,
I would like to request you that I have one problem in CGI. I personally feel that there are the master of the CGI so I think this is right place to ask the Query.

If you would help to solve it then I am heartly greatful to you. if you spare few minutes then it would be appreciateable. But if not then also I am heartly greatful to you for reading.

I have 2 websites and on 1 website I'm using a Form which submits the data (or you can say send the data) to my second website and I'm using GEt Method in Form.

The problem is I have to use the Form with GET method (especially not with POST method, I only want to use GET method). Now after pressing the submit button and on the next page I want to get the Referer, I want to know from where the user is coming.

Below is the code:
---------------------- Form.HTML --------------------------------
<form action="form_submit.pl" method=get>
Name <input type="text" name="username">
Age <input type="password" name="password">
<input type="submit">
</form>


OR we can also call the below file by this:
http://www.domain.com/cgi-bin/form_submit.pl?username=Jhon&password=99
But I need the referer by using Get Method or QueryString.

------------------- form_submit.pl ---------------------
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "QUERY_STRING=$ENV{'QUERY_STRING'}<br>\n";
print "HTTP_X_FORWARDED_FOR=$ENV{'HTTP_X_FORWARDED_FOR'}<br>\n";

if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $request, $ENV{'CONTENT_LENGTH'});
} elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) {
$request = $ENV{'QUERY_STRING'};
} else {
while (read (STDIN, $chunck, 1))
{
$request = $request . $chunck;
}
$request =~ tr/\n//d;
}

$ip_address = $ENV{'REMOTE_ADDR'};
@numbers = split(/\./, $ip_address);
$ip_number = pack('C4', @numbers);
($host) = (gethostbyaddr ($ip_number, 2)) [0];

print "Remote Address = $ip_address <br>";
print "host = $host <br>";
print "referer = $ENV{'HTTP_REFERER'}<br>\n";
print $request;

print "<p>I am getting all the above things but UNABLE to get the referer. Can you tell me how to get the Referer when the request comes from GET method OR it's coming from Query String. <p> I am heartly greatful to you if you tell me Is there any method or way in CGI to do it";



Please help me.
 

Forum statistics

Threads
80,945
Messages
248,478
Members
20,683
Latest member
tombarko8
Top