problem CGI

J

john.swilting

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

john.swilting

john.swilting said:
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>
 
B

Brian McCauley

<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.
 
J

john.swilting

Brian said:
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');
 
J

john.swilting

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
 
J

john.swilting

Michele said:
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(' ');
 
J

Joe Smith

john.swilting said:
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
 
U

Uri Guttman

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
 
J

john.swilting

Michele said:
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
 
J

john.swilting

john.swilting said:
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
 
J

john.swilting

john.swilting said:
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
 
J

john.swilting

john.swilting said:
#!/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
 
D

Dr.Ruud

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';
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top