Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: how to use -nosticky in CGI?

by chargrill (Parson)
on Dec 18, 2006 at 20:42 UTC ( #590552=note: print w/replies, xml ) Need Help??


in reply to Re^4: how to use -nosticky in CGI?
in thread how to use -nosticky in CGI?

Thank you for giving me some more to go on. I can understand your not wishing to share proprietary (or maybe incriminating! :) information. Please know that demonstrations of bad behavior can really pretty easily be mocked up (see below ;).

I looked at the docs for CGI (which I haven't done in a very very very long time, and I think my locally installed copy is a little rusty, hence not using things like start_table) and really can't undertand what's causing this behavior.

I whipped up something that is self contained, possibly recreates the functionality your form has (I could be way off, though), and doesn't really do anything other than to exercise the code - if you hit "New Entry", nothing happens, since the data shown in the rows is coming out of an unchangeable __DATA__ section.

#!/usr/bin/perl use CGI qw/:standard/; my $q = new CGI; %in = map { $_ => $q->param( $_ ) } $q->param; print "Content-type: text/html\n\n"; print "<table border='1' cellpadding='5'>"; print Tr( td( [ "First", "Last", "<a href='testme.cgi?action=add'>add</a>" ] ) ); while( <DATA> ){ for( [ split /\s/, $_ ] ){ print Tr( td( [ $_->[0], $_->[1], "<a href='testme.cgi?action=edit&firstname=$_->[0]" ."&lastname=$_->[1]'>edit me</a>" ] ) ); } } print "</table>"; print start_form; if( $in{action} eq 'edit' || $in{action} eq 'add'){ if ($in{'submit'} eq 'New Entry') { print table( Tr( { -valign => "TOP" }, [ td( [ "First Name", textfield( -name => 'firstname', -size => 80 ) ] ), td( [ "Last Name", textfield( -name => 'lastname', -size => 80 ) ] ) ] ) ); } else { print table( Tr( { -valign => "TOP" }, [ td( [ "First Name", textfield( -name => 'firstname', -size => 30, -value => $firstname ) ] ), td( [ "Last Name", textfield( -name => 'lastname', -size => 30, -value => $lastname ) ] ) ] ) ); }; print submit( -name=>'submit', -value=>'New Entry'); } __DATA__ Kent Cowgill J CK Fred Patterson Steve Peterson

I would be really interested if you follow these steps:

  1. Click one of the "edit me" links
  2. Click "New Entry"
  3. Click "add"

... and you see the behavior recreated (i.e. whatever was in there last during an "edit" shows up after clicking "add".

Otherwise, pvbcharon might be on to something - you're seeing persistence of data that has a source other than your code.



--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2019-10-19 09:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?