CGI param() function parameters


 
Thread Tools Search this Thread
Top Forums Web Development CGI param() function parameters
# 1  
Old 01-12-2012
CGI param() function parameters

Hello again!
Three posts in this forum now, as I am trying to understand how CGI is running and the interaction of the input and output with the server/browser. Very confused with them, especially with the param() function that I was trying to figure out how the parameters of it were passed in between. Say, with the following script, I swallowed it down with little digestion, and it is working. But I do not know how to modify it for my own purpose.
I seem understanding the general idea of the cooperation among CGI, Apache2 and the Browser, but I am not sure, especially, the CGI functions in detail. In this example, I was expecting "key - value" pairs from param() function as
Code:
name      Linux
address1   123 streat
address2    Room 123
city           New York
State          NJ
zip             1X23Y4
country       USA
button         Enter

but actually nothing was printed. Can anyone explain it for me how these parameters are passed, please? Thanks a lot!

Code:
#!/usr/bin/perl -wT
#textform.pl

use strict;
use CGI;
my $q = CGI->new;

# Starters.
print $q->header, $q->start_html('Address info');

# Create a form with text entry fields.
print $q->start_form,
    $q->h1('Please enter your address below.'),$q->p,
    'Name:',$q->textfield(-name => 'name'),$q->br,
    'Address:',$q->textfield(-name => 'address1'),$q->br,
    'Address:',$q->textfield(-name => 'address2'),$q->br,
    'City:',$q->textfield(-name => 'city'),
    'State/Province:',$q->textfield(-name => 'state'),
    'Zip/Postal code:',$q->textfield(-name => 'zip'),$q->br,
    'Country:',$q->textfield(-name => 'country'),$q->p,
    $q->submit('button','Enter'),
    $q->end_form;
print "The parameters of the CGI object (\$q) are: ", "\n";
foreach my $member ($q->param()) {     #Line 24
print "$member\t";                                   #Line 25
}                                                            #Line 26
print "\n";
# End the document.
print $q->end_html;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

<Mail> attachment param is not working under system function

Hi Guys, I have executed the mail command that has attachment with filename as current date enclosed in system function that is added under awk command. I have used awk command to check if the error code is present in the file then email command sends an email with subject Error Code ,body... (2 Replies)
Discussion started by: reminisce
2 Replies

2. Shell Programming and Scripting

PERL: Function calling using parameters

I have two variables. I need to call them using the same function my $dat1 ="abc"; my $dat2 ="def"; my $check; filecheck($dat1,$dat2); sub filecheck($) { $check = shift; print "first name is $check\n"; } print "this is fine\n"; sub filecheck($) { $check = shift; print "second... (2 Replies)
Discussion started by: irudayaraj
2 Replies

3. Programming

structure pointer array as function parameters

if i create an array of pointers to a structure "struct node" as: struct node *r; and create "n" number of "linked lists" and assign it to the various struct pointers r using some function with a return type as structure pointer as: r=multiplty(.......) /*some parameters*/ is... (2 Replies)
Discussion started by: mscoder
2 Replies

4. Shell Programming and Scripting

Passing the parameters using a function

Hi All, I am new to shell scripting required some help in passing the parameter value to the shell script. I am writing a shell script, in the script I have created two functions as below. first function get_trend_ids () { Here I am connecting to the database and getting all the... (3 Replies)
Discussion started by: shruthidwh
3 Replies

5. Shell Programming and Scripting

Need help on bind param function in perl

Hi, I want to know what exactly bind paameter does? what exactly bind_param( 1, $siteName ) means? what 1 means? In some examples the bind_param is set like this: bind_param( 2, $siteName1 ) bind_param( 3, $siteName2 ) $sth = $dbh->prepare( " SELECT name,... (1 Reply)
Discussion started by: vanitham
1 Replies

6. Shell Programming and Scripting

bash script function parameters

I have a question about bash script. Can I create a function there that accept parameters like functions in program language? (2 Replies)
Discussion started by: programAngel
2 Replies

7. Shell Programming and Scripting

call function with different parameters position

Hi I would like to call function in my script couple of times. But each time with different parameters position. In line 57 I don't know how to call it without typing $1 and $ parameters ? #!/bin/ksh 2 3 4 function First 5 { 6 7 # $1 - name 8 ... (2 Replies)
Discussion started by: presul
2 Replies

8. Shell Programming and Scripting

Pass parameters to function

Hi, for example I have this function: function get_param () { test=echo "some string" test2=echo "someother string" } I want to call this function and get test or test2 result, how do I do that ? Thank you (2 Replies)
Discussion started by: ktm
2 Replies

9. Shell Programming and Scripting

isset() PHP function in cgi bash scripts

Hi! Some minutes ago I've posted a question related with sed regexps because I need to catch information sended with forms with GET action. This is the post: https://www.unix.com/shell-programming-scripting/127800-regular-expression-sed.html But now I have a new question. Does cgi scripts have... (0 Replies)
Discussion started by: GagleKas
0 Replies

10. Shell Programming and Scripting

Parameters for function in Shell script

Hi, I am having a function inside a shell script. The Shell script is called with parameters and one of the parameter is passed to a SQL script inside the function. But when the function is called inside the shell script, the SQL script is not called. Do the shell parameter has to be... (3 Replies)
Discussion started by: srimenon09
3 Replies
Login or Register to Ask a Question