How to Pass Variables to CGI From a Frameset

One of the ways that web applications and servers interact is through a common gateway interface, or CGI. If you are developing a web application or a website, you may need to pass variables and other kinds of data to the web server, which receives them through CGI. This tutorial will show you how to use the Perl web scripting language to send variables to the server's CGI.

Instructions

    • 1

      Create a new Perl document using a plain-text editing application or code editing application.

    • 2

      Pass variables to CGI by using HTTP and the GET method to send data to CGI over the HTTP connection protocol by creating a modifiable URL, for example:

      http://www.examplewebsite.com/cgi-bin/example.cgi?username=John&password=smith

    • 3

      Code the Perl script that will enable the example URL above to accept the username and password parameters in the URL by using the following script:

      local ($buffer, @pairs, $pair, $name, $value, %FORM);

      $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;

      if ($ENV{'REQUEST_METHOD'} eq "GET")

      {

      $buffer = $ENV{'QUERY_STRING'};

      }

      $username = $FORM{username};

      $password = $FORM{password};

    • 4

      Save the Perl document and upload it to the same web server that hosts your web application or website, then reference the script as needed in other parts of your code.

Related Searches:

References

Comments

Related Ads

Featured