Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

CGI & PHP Referer Problem

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

  1. ashish9

    ashish9 Registered

    Nov 17, 2003
    Likes Received:
    Trophy Points:
    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="" method=get>
    Name <input type="text" name="username">
    Age <input type="password" name="password">
    <input type="submit">

    OR we can also call the below file by this:
    But I need the referer by using Get Method or QueryString.

    ------------------- ---------------------
    print "Content-type:text/html\n\n";
    print "QUERY_STRING=$ENV{'QUERY_STRING'}<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.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice