Slide 3.9: Writing CGI scripts
Slide 3.11: CGI security concerns
Home

REQUEST_METHOD: GET or POST


REQUEST_METHOD: GET
The input values from the form are sent as part of the URL, and saved in the QUERY_STRING environment variable. The advantage of the GET method is the page can be retrieved again by entering the URL. For example, after submit the keywords: CGI and Perl, to the Yahoo, the URL is changed to the following string:
   http://search.yahoo.com/bin/search?p=cgi%20perl
The GET method is not a secure method of sending data since the data is passed through as part of the URL, it will show up in the web server's logfile. The following demonstration shows an example of the GET method:
      Input1:    Input2: 
The GET method uses the function url_param to retrieve web input:

#!/usr/bin/perl
use CGI; 
$query  = new CGI;
$act    = $query->param( 'act'  );
$string = $query->query_string;
$input1 = $query->url_param( 'input1' );

REQUEST_METHOD: POST
Data is sent as a standard input stream to the program. For example, if the input type names are email, password, and button, respectively, the standard input may contain the following string after users enter the requested information and submit:
 email=userid%40cs.und.edu&password=351&button=customer
The following demonstration shows an example of the POST method:
      Input1:    Input2: