Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: CGI auto incrementing table

by benn (Priest)
on Aug 11, 2003 at 12:32 UTC ( #282833=note: print w/ replies, xml ) Need Help??


in reply to CGI auto incrementing table

If you show us some code, explaining what the 'strange behaviour' is, I'm sure we can help - it's rather difficult with just a textual description :)

Cheers, Ben.


Comment on Re: CGI auto incrementing table
Re: Re: CGI auto incrementing table
by Discipulus (Curate) on Aug 11, 2003 at 12:54 UTC
    Here the code
    #perl! -w use CGI qw /:standard -nph/; $|++; $q=new CGI; my @commands = qw(ping traceroute whois ); my $dispatch = { ping => sub { return my_ping($_[0])}, traceroute => sub { return my_traceroute($_[0])}, }; %corrispondenze=( 'wy2khost1'=>'193.110.128.41' , 'wy2khost2'=>'193.110.128.42', 'wy2khost3'=>'193.110.128.52', 'wy2khost4'=>'193.110.136.130' ); print $q->header(); print $q->start_html(-bgcolor=>"#000099",-text=>"#FFCC00"); print $q->h2('prova'); print $q->start_form(-method=>'POST',-action=>'formDB2.cgi'); print $q->p('immettere qs '); print $q->textfield(-name=>'qs',-value=>""); print $q->submit; $val=$q->param('qs'); if ($val){print $q->hr;print "Hai messo: $val";print $q->hr;&trovabis( +$val)} sub trovabis { $indice=0; $cosa=shift; chomp $cosa; open (FH, 'C:\\Inetpub\\wwwroot\\PERL\\cgi-bin\\030716.txt')||die $! +; while (<FH>){push(@logline, $_)} foreach $record(@logline) { my @ciccio=split/\?/,$record; pop @ciccio; #toglie il valore nullo perché la stringa si chiude c +on un ? if ($ciccio[2]=~/$cosa/ || $ciccio[3]=~/$cosa/ || $ciccio[14]=~/$co +sa/ ) { $indice++; print table({-border=>0,-width=>"100%", -cellspacing=>"0", -cellpa +dding=>"0"}, Tr({-align=>LEFT,-valign=>TOP}, [ td([$q->h5("$indice)"),"$ciccio[0]($corrispondenze{$ciccio[ +0]})"]), td([$q->a({-href=>"http://$ciccio[2]",target=>new},"$ciccio +[2]"),"$ciccio[4]"]), td(["$ciccio[3]","$ciccio[7]"]), td(['',"$ciccio[9]"]), td(['',"$ciccio[10]"]), td(['',"$ciccio[11]"]), td(['',"$ciccio[14]"]), td(['',"$ciccio[15]"]), ] ) ); print $q->p("\$ciccio[2]vale $ciccio[2]"); print $q->start_form(-method=>'POST',-action=>'formDB2.cgi'); print $q->hidden(-name=>'val',-value=>"$ciccio[2]"); print $q->submit(ucfirst($_)) foreach (@commands); print $q->end_form; foreach (@commands) { $dispatch->{$_}->("$ciccio[2]") if (defined $q->param(ucfirst( +$_))); #$q->param('val') } print $q->hr; } } } sub my_ping { my $pingalo=shift; open (FH,"ping -n 1 -l 8 $pingalo|"); while (<FH>){if ($_=~/(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/){$risu +ltato_ping=$1}} close FH; print "$pingalo pinga su $risultato_ping";#debug info }
      Your script seems to be passing the name you're interested in in the CGI parameter name, but I never see you looking at that. When the user clicks on the button, you should find the value you put in the hidden field name in $q->param("name").

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://282833]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-12-29 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (186 votes), past polls