The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

CGI & PHP Referer Problem

Discussion in 'General Discussion' started by ashish9, Nov 18, 2003.

  1. ashish9

    ashish9 Registered

    Joined:
    Nov 17, 2003
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    1
    Hello All,
    I would like to request you that I have one problem in CGI and PHP. It's backend script. I personally feel that there are the master of the CGI and PHP 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.

    You can answer in CGI or PHP because in both languages I have same problem

    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.
     
Loading...

Share This Page