problem CGI

Discussion in 'Perl Misc' started by john.swilting, Feb 14, 2007.

  1. I have a problem
    how to recover the data of a form
    the form is a large table with images and buttons to order
    john.swilting, Feb 14, 2007
    #1
    1. Advertising

  2. john.swilting wrote:

    > I have a problem
    > how to recover the data of a form
    > the form is a large table with images and buttons to order

    <form action="http://localhost/cgi-bin/vente.cgi" method="post">
    <table>
    <tbody>
    <tr>
    <td>&nbsp;<img src="img168_2.GIF" width="200" height="176" border="0"
    alt=""><hr><i>image numero 1 prix 39.99euros</i></hr><hr /><input name="1"
    type="image"
    src="../commander.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
    href="img168_2.GIF">agrandir</a></td></td>
    <td>&nbsp;<img src="img168_2.GIF" width="200" height="176" border="0"
    alt=""><hr><i>image numero 2 prix 39.99euros</i></hr><hr /><input name="2"
    type="image"
    src="../commander.gif"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
    href="img168_2.GIF">agrandir</a></td></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    john.swilting, Feb 14, 2007
    #2
    1. Advertising

  3. Michele Dondi wrote:

    > On Wed, 14 Feb 2007 12:52:14 +0100, "john.swilting"
    > <> wrote:
    >
    >>I have a problem
    >>how to recover the data of a form

    >
    > perldoc CGI
    >
    >>the form is a large table with images and buttons to order

    >
    > Is that relevant?
    >
    >
    > Michele


    you cannot help me too a little more perldoc cgi me
    john.swilting, Feb 14, 2007
    #3
  4. On Feb 14, 12:34 pm, "john.swilting" <> wrote:
    > john.swilting wrote:
    > > I have a problem
    > > how to recover the data of a form
    > > the form is a large table with images and buttons to order


    <input name="1" type="image" src="../commander.gif"/>

    A description of what the client should send when the user hits a
    graphical submit button can be found here:

    http://www.w3.org/TR/html4/interact/forms.html#h-17.4.1

    It is unclear what problem you are experiencing.

    Note that only one submit button at a time can ever be "successful".

    http://www.w3.org/TR/html4/interact/forms.html#h-17.13.2

    Try to write Perl to show us the problem.

    If you can't do that try your best to explain in English.

    If necessary you can give more detail in your native language - this
    is an international group someone will probably translate it.
    Brian McCauley, Feb 14, 2007
    #4
  5. Brian McCauley wrote:

    > A description of what the client should send when the user hits a
    > graphical submit button can be found here:


    I am afraid to find me with much
    my $1 = $cgi->param('1');
    john.swilting, Feb 14, 2007
    #5
  6. john.swilting wrote:

    > Brian McCauley wrote:
    >
    >> A description of what the client should send when the user hits a
    >> graphical submit button can be found here:

    >
    > I am afraid to find me with much
    > my $1 = $cgi->param('1');

    that will be a gas works

    :)
    john.swilting, Feb 14, 2007
    #6
  7. john.swilting wrote:

    > john.swilting wrote:
    >
    >> Brian McCauley wrote:
    >>
    >>> A description of what the client should send when the user hits a
    >>> graphical submit button can be found here:

    >>
    >> I am afraid to find me with much
    >> my $1 = $cgi->param('1');

    > that will be a gas works
    >
    > :)

    :-[
    john.swilting, Feb 14, 2007
    #7
  8. john.swilting

    Guest

    On Feb 14, 11:44 am, Michele Dondi <> wrote:
    > On Wed, 14 Feb 2007 15:22:39 +0100, "john.swilting"


    > >that will be a gas works

    >
    > I beg your pardon?!?


    I think the Bablefish French->English translator may have something to
    do with these garbled expressions...
    , Feb 14, 2007
    #8
  9. Michele Dondi wrote:

    > On Wed, 14 Feb 2007 14:48:34 +0100, "john.swilting"
    > <> wrote:
    >
    >>I am afraid to find me with much
    >>my $1 = $cgi->param('1');

    >
    > Don't! Numbered variables have a special meaning. Try
    >
    > my $one = $cgi->param('1');
    >
    > instead.
    >
    >
    > Michele

    ok
    john.swilting, Feb 15, 2007
    #9
  10. wrote:

    > On Feb 14, 11:44 am, Michele Dondi <> wrote:
    >> On Wed, 14 Feb 2007 15:22:39 +0100, "john.swilting"

    >
    >> >that will be a gas works

    >>
    >> I beg your pardon?!?

    >
    > I think the Bablefish French->English translator may have something to
    > do with these garbled expressions...

    gas works
    bablefish translation

    usine à gaz en français
    john.swilting, Feb 15, 2007
    #10
  11. Michele Dondi wrote:

    > On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
    > <> wrote:
    >
    >>you cannot help me too a little more perldoc cgi me

    >
    > A little more? No I can't. I can help you a little less: try the
    > param() function/method.
    >
    >
    > HTH,
    > Michele

    I will find myself with hundreds of -> param(' ');
    john.swilting, Feb 15, 2007
    #11
  12. john.swilting wrote:

    > Michele Dondi wrote:
    >
    >> On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
    >> <> wrote:
    >>
    >>>you cannot help me too a little more perldoc cgi me

    >>
    >> A little more? No I can't. I can help you a little less: try the
    >> param() function/method.
    >>
    >>
    >> HTH,
    >> Michele

    > I will find myself with hundreds of -> param(' ')

    I should not make a loop for on all the data of the form
    john.swilting, Feb 15, 2007
    #12
  13. john.swilting

    Joe Smith Guest

    john.swilting wrote:

    > I am afraid to find me with much
    > my $1 = $cgi->param('1');


    It is documented in 'perldoc CGI':

    FETCHING THE PARAMETER LIST AS A HASH:

    Many people want to fetch the entire parameter list as a hash in which
    the keys are the names of the CGI parameters, and the values are the
    parameters' values.

    Therefore, you can use something like this:

    %params = $cgi->Vars;
    for my $key (sort keys %params) {
    print "The value for $key is '$params{$key}'\n",br;
    }

    -Joe
    Joe Smith, Feb 15, 2007
    #13
  14. john.swilting

    Uri Guttman Guest

    >>>>> "JS" == Joe Smith <> writes:

    JS> Therefore, you can use something like this:

    JS> %params = $cgi->Vars;
    JS> for my $key (sort keys %params) {
    JS> print "The value for $key is '$params{$key}'\n",br;
    JS> }

    the problem with that is that multivalued params are not an array but a
    string with a separator. so you have to check each param to see if it is
    single or multivalued. param() by itself will return a list if the param
    is multivalued. i don't know why the Vars method is so broken but i
    think it is a backwards compatibility issue. and even if so, why isn't
    there a method which does return a proper hash of scalars and arrays. i
    had to roll my own by calling param in a loop (map really) over a list
    the params.

    uri

    --
    Uri Guttman ------ -------- http://www.stemsystems.com
    --Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
    Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
    Uri Guttman, Feb 15, 2007
    #14
  15. Michele Dondi wrote:

    > On Thu, 15 Feb 2007 03:16:36 +0100, "john.swilting"
    > <> wrote:
    >
    >>> A little more? No I can't. I can help you a little less: try the
    >>> param() function/method.
    >>>

    >>I will find myself with hundreds of -> param(' ');

    >
    > If you need to handle hundreds of *different* situations, then that
    > may well be the only thing to do. If they are not completely different
    > but have something in common, chances are that the common parts may be
    > factored away. Hard to say without seeing some code, anyway. Thus try
    > to concoct a minimal example of the same nature of your program (but
    > devoid of any irrelevant detail) in which the calls are a tenth
    > insteads of hundreds. Then someone more knowledgeable than you and me
    > may well be able to help you.
    >
    >
    > Michele

    I will try to make a small example this evening 16h pm paris
    john.swilting, Feb 15, 2007
    #15
  16. john.swilting wrote:

    > john.swilting wrote:
    >
    >> Michele Dondi wrote:
    >>
    >>> On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
    >>> <> wrote:
    >>>
    >>>>you cannot help me too a little more perldoc cgi me
    >>>
    >>> A little more? No I can't. I can help you a little less: try the
    >>> param() function/method.
    >>>
    >>>
    >>> HTH,
    >>> Michele

    >> I will find myself with hundreds of -> param(' ')

    > I should not make a loop for on all the data of the form

    I carried out some small tests and there is only 1 parameter which is master
    key with the script how to let to know which and to know that value I do
    not know how to make
    john.swilting, Feb 15, 2007
    #16
  17. john.swilting wrote:

    > john.swilting wrote:
    >
    >> john.swilting wrote:
    >>
    >>> Michele Dondi wrote:
    >>>
    >>>> On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
    >>>> <> wrote:
    >>>>
    >>>>>you cannot help me too a little more perldoc cgi me
    >>>>
    >>>> A little more? No I can't. I can help you a little less: try the
    >>>> param() function/method.
    >>>>
    >>>>
    >>>> HTH,
    >>>> Michele
    >>> I will find myself with hundreds of -> param(' ')

    >> I should not make a loop for on all the data of the form

    > I carried out some small tests and there is only 1 parameter which is
    > master key with the script how to let to know which and to know that value
    > I do not know how to make

    #!/usr/bin/perl -w
    use strict;
    use diagnostics;
    use CGI qw/:standard escapeHTML/;
    use Data::Dumper;

    my $cgi = new CGI;

    my $one = $cgi->param('commander1');
    ##my $two = $cgi->param('commander2');
    my $dumper1 = print Dumper $one;
    ##my $dumper2 = print Dumper $two;
    sub AFFICHAGE{
    my($one) = @_;
    print header();
    print start_html("Dumper");

    print p("fileinfo",tt(escapeHTML($dumper1)));

    ## print p("fileinfo",tt(escapeHTML($dumper2)));
    print end_html();
    }

    AFFICHAGE($one);
    perl /var/www/cgi-bin/ventedumper ? commander1=1
    it always answer me the same thing with different values with the param
    john.swilting, Feb 15, 2007
    #17
  18. john.swilting wrote:

    > john.swilting wrote:
    >
    >> john.swilting wrote:
    >>
    >>> john.swilting wrote:
    >>>
    >>>> Michele Dondi wrote:
    >>>>
    >>>>> On Wed, 14 Feb 2007 13:36:51 +0100, "john.swilting"
    >>>>> <> wrote:
    >>>>>
    >>>>>>you cannot help me too a little more perldoc cgi me
    >>>>>
    >>>>> A little more? No I can't. I can help you a little less: try the
    >>>>> param() function/method.
    >>>>>
    >>>>>
    >>>>> HTH,
    >>>>> Michele
    >>>> I will find myself with hundreds of -> param(' ')
    >>> I should not make a loop for on all the data of the form

    >> I carried out some small tests and there is only 1 parameter which is
    >> master key with the script how to let to know which and to know that
    >> value I do not know how to make

    > #!/usr/bin/perl -w
    > use strict;
    > use diagnostics;
    > use CGI qw/:standard escapeHTML/;
    > use Data::Dumper;
    >
    > my $cgi = new CGI;
    >
    > my $one = $cgi->param('commander1');
    > ##my $two = $cgi->param('commander2');
    > my $dumper1 = print Dumper $one;
    > ##my $dumper2 = print Dumper $two;
    > sub AFFICHAGE{
    > my($one) = @_;
    > print header();
    > print start_html("Dumper");
    >
    > print p("fileinfo",tt(escapeHTML($dumper1)));
    >
    > ## print p("fileinfo",tt(escapeHTML($dumper2)));
    > print end_html();
    > }
    >
    > AFFICHAGE($one);
    > perl /var/www/cgi-bin/ventedumper ? commander1=1
    > it always answer me the same thing with different values with the param

    perl /var/www/cgi-bin/ventedumper.cgi?commander=1
    john.swilting, Feb 15, 2007
    #18
  19. john.swilting

    Dr.Ruud Guest

    john.swilting schreef:

    > #!/usr/bin/perl -w
    > use strict;


    Make that:

    #!/usr/bin/perl
    use strict;
    use warnings;

    (unless you run a very old perl)


    Or Abigail-style:

    #!/usr/bin/perl

    use warnings;
    use strict;
    no warnings 'syntax';

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Feb 15, 2007
    #19
  20. Dr.Ruud wrote:

    > unless you run a very old perl

    why
    I did new to a post anybody does not answer me
    john.swilting, Feb 15, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jürgen Exner

    Re: CGI Perl "use CGI" statement fail

    Jürgen Exner, Jul 31, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,254
    Jürgen Exner
    Jul 31, 2003
  2. Shailan
    Replies:
    2
    Views:
    902
    Shailan
    Dec 15, 2003
  3. John Smith
    Replies:
    0
    Views:
    3,014
    John Smith
    May 15, 2006
  4. Luigi Ma
    Replies:
    0
    Views:
    131
    Luigi Ma
    Nov 21, 2007
  5. BestFriend
    Replies:
    2
    Views:
    753
Loading...

Share This Page