Results 1 to 2 of 2

Thread: CGI Querystrings

  1. #1

    Thread Starter
    Hyperactive Member richy's Avatar
    Join Date
    Jan 1999
    Location
    Liverpool, England
    Posts
    353
    How do I request Querystring in CGI (eg I want to get the string 'thedata' from www.website.com/test.pl?thedata=bob)

  2. #2
    Lively Member
    Join Date
    Jan 2001
    Location
    Perth, Western Australia
    Posts
    108
    by calling this sub below, when the script is first executed it will place any querys into an array.
    ie.. for your example it would be,

    Code:
    parse_form;
    $thedata = $input{'thedata'};
    #ie.. thedata would equal bob

    (the parse form sub that is called,
    Code:
    sub parse_form {
       read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
       if (length($buffer) < 5) {
             $buffer = $ENV{QUERY_STRING};
        }
       @pairs = split(/&/, $buffer);
       foreach $pair (@pairs) {
          ($name, $value) = split(/=/, $pair);
    
          $value =~ tr/+/ /;
          $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    
          $input{$name} = $value;
       }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width