Click here to get back home

using cgi.pm

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
using cgi.pm Ela 03-27-2008
---> Re: using cgi.pm Joost Diepenmaa...03-27-2008
Get Chitika Premium
Posted by Ela on March 27, 2008, 9:04 am
Please log in for more thread options
After studying:

http://search.cpan.org/src/LDS/CGI.pm-3.34/cgi_docs.html#checkbox_group

I still don't understand how to tell one cgi to call another cgi to handle
the information of a submited form, after a user has submited his form with
some choices selected. Could anybody shed some light?



Posted by Joost Diepenmaat on March 27, 2008, 9:56 am
Please log in for more thread options

> After studying:
>
> http://search.cpan.org/src/LDS/CGI.pm-3.34/cgi_docs.html#checkbox_group
>
> I still don't understand how to tell one cgi to call another cgi to handle
> the information of a submited form, after a user has submited his form with
> some choices selected. Could anybody shed some light?

In general, you just don't do that. If you want to put processing code
in separate files, just use those files from the same CGI program. IOW,
use modules. That's more efficient and less error prone than trying
to invoke stand-alone scripts from each other (not to mention that doing
that will probably not work out of the box for CGI scripts that read
POST data).

HTH,
Joost.


--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Posted by Ela on March 27, 2008, 10:31 am
Please log in for more thread options
> In general, you just don't do that. If you want to put processing code
> in separate files, just use those files from the same CGI program. IOW,
> use modules. That's more efficient and less error prone than trying
> to invoke stand-alone scripts from each other (not to mention that doing
> that will probably not work out of the box for CGI scripts that read
> POST data).
>
> HTH,
> Joost.

But in the sense of putting the search and fetch functions in the same cgi,
how come results can be generated after accepting users' input parameters? A
simple example based on my simplified codes will be appreciated~

#!/usr/bin/perl

use CGI qw(:standard);

$query = new CGI;

print $query->header;

print $query->startform;
print "Title: ",$query->textfield(-name=>'title', -justification=>'RIGHT');

print $query->submit(-name=>'button_name', -value=>'Get !');
print $query->endform;
print $query->end_html;

#the following print can be executed successfully but the resultant page is
just wield....
print $query->param('title');
print "<BR>";



Posted by smallpond on March 27, 2008, 11:55 am
Please log in for more thread options
>
>
> > In general, you just don't do that. If you want to put processing code
> > in separate files, just use those files from the same CGI program. IOW,
> > use modules. That's more efficient and less error prone than trying
> > to invoke stand-alone scripts from each other (not to mention that doing
> > that will probably not work out of the box for CGI scripts that read
> > POST data).
>
> > HTH,
> > Joost.
>
> But in the sense of putting the search and fetch functions in the same cgi,
> how come results can be generated after accepting users' input parameters? A
> simple example based on my simplified codes will be appreciated~
>
> #!/usr/bin/perl
>
> use CGI qw(:standard);
>
> $query = new CGI;
>
> print $query->header;
>
> print $query->startform;
> print "Title: ",$query->textfield(-name=>'title', -justification=>'RIGHT');
>
> print $query->submit(-name=>'button_name', -value=>'Get !');
> print $query->endform;
> print $query->end_html;
>
> #the following print can be executed successfully but the resultant page is
> just wield....
> print $query->param('title');
> print "<BR>";


The process that prints out a web page form is not the same process
that gets the result of filling it out and pressing the submit
button. They don't have to have any connection and don't have to
be on the same web server. I can create a search form on my website
and submit it to google, for example.

It is sometimes convenient to do them both from one cgi and sort
out which call is being made from the params, but if you are just
getting started try making the form with a static web page and
handling only the submit in the cgi. Work up from there.
--S

Posted by xhoster on March 27, 2008, 12:16 pm
Please log in for more thread options
>
> #!/usr/bin/perl
>
> use CGI qw(:standard);
>
> $query = new CGI;
>
> print $query->header;
>
> print $query->startform;
> print "Title: ",$query->textfield(-name=>'title',
> -justification=>'RIGHT');
>
> print $query->submit(-name=>'button_name', -value=>'Get !');
> print $query->endform;
> print $query->end_html;

You shouldn't lie like that. You told it that this is the end of the html,
but then you go on to send more html. Most browsers will handle this
deception gracefully, but it is still bad practice.

>
> #the following print can be executed successfully but the resultant page
> # is just wield....
> print $query->param('title');
> print "<BR>";

What is weird about it? It does exactly what I thought it would do, the
misplaced end_html not withstanding. First it shows the form,
unconditionally, then it shows the results from the just-submitted form,
if any. That is what you told it to do. What did you want it to do?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap