Read the data for a CGI GET request : Form « CGI « Perl






Read the data for a CGI GET request

 

    <HTML>
    <HEAD>
    <TITLE>CGI Form</TITLE>
    </HEAD>
    <BODY>
    <FORM METHOD="GET" ACTION="index.pl">
    <P>Name: <INPUT TYPE = "text" NAME = "name" VALUE = "" ></P>
    <P>Address: <INPUT TYPE = "text" NAME = "street" VALUE = "" ></P>
    City: <INPUT TYPE = "text" NAME = "city" VALUE = "" >
    State: <INPUT TYPE = "text" NAME = "state" VALUE = "" >
    Zip: <INPUT TYPE = "text" NAME = "zip" VALUE = "" >
    <P>Overall rating:</P>
    Needs Improvement: <INPUT TYPE = "radio" NAME = "rating" VALUE = "NI">
    Average: <INPUT TYPE = "radio" NAME = "rating" VALUE = "AV">
    Above Average: <INPUT TYPE = "radio" NAME = "rating" VALUE = "AA">
    Excellent: <INPUT TYPE = "radio" NAME = "rating" VALUE = "EX">
    <BR>
    <P>Comments:</P>
    <P><TEXTAREA NAME = "comments"></TEXTAREA></P>
    <INPUT TYPE = "reset" name="reset" value = "Reset the Form">
    <INPUT type = "submit" name="submit" value = "Submit Comment">
    </FORM></H4>
    </BODY>
    </HTML>

    ############################################################

    $requestType = $ENV{"REQUEST_METHOD"};

    print "Content-type: text/plain\n\n";
    if($requestType eq "GET")
    {
        &readGetData(*data);
        # Print the data that we read
        print "The GET data is:\n\n";
        print $data;
        print "\n";
    }
    sub readGetData
    {
        local(*queryString) = @_ if @_;
        $queryString = $ENV{"QUERY_STRING"};
        return 1;
    }

   
  








Related examples in the same category

1.Form Input Types
2.Demonstrates GET method with HTML form.
3.Demostrates POST method with HTML form.
4.Demonstrates use of CGI.pm with HTML form.
5.Create HTML form with CGI
6.Get form submitted value
7.Using param() function to get parameter
8.Using CGI function to check the parameter
9.Create a form and set the method and action
10.Create a form with submit button
11.Process form with regular expression: first name and last name
12.Process form with regular expression: date
13.Process form with regular expression: time
14.Generate the HTML form
15.Printing the Name Input Using the CGI Module
16.Get form value with param
17.Generate and Process Forms
18.Form Mail
19.Form based table editing
20.Create a form with Perl code
21.Code to Accept Input with the CGI Module
22.Capitalize the first letter of each parameter using ucfirst
23.A Form-Based Example
24.Learn about the current CGI request
25.Read the data passed to a script on the command line?
26.Decoding the Input Data
27.The POST Method
28.Verifying a username and a password
29.Sample Database Query
30.Writing a cookie to the client computer
31.Add a New Phone Number
32.Sessions - Preserving State
33.Separate the form and perl script
34.Add form data to database
35.Passing parameter to perl CGI code
36.EMail sending form
37.Guest book form
38.Data-Entry Forms in Web Pages
39.Using LI
40.Using the option select box
41.Reading text in textarea
42.Querying all the parameters