Nov 3, 2012, 6:51 AM
Re: [ningji] cgi.pm question: difference between param and cookie
it's working, :) Thanks very much !
but this is what i don't understand,
$q->param(-name=>"first_var", -value => $v1);
$q->param(-name=>"second_var", -value => $v2);
What do you expect these lines to do? I can assure you that they don't do what you expect and are not needed/wanted. Remove them.
thought these 2 lines are updating the values for "first_var", "second_var".
this is what param( ) for.
is it because these 2 lines are not inside the form block ?
Sounds like you need to read the CGI documentation more carefully.
The param() method is used (almost exclusively) to RETRIEVE the SUBMITTED form field data. It is also overloaded so that you can add/update/set a parameter that is used during this execution of the script but is never used to update a form field that the user sees and sends back for the next invocation of the script.
In your case, you're updating the values of those params, but never use them after that, which makes it pointless.
The hidden form fields are doing what you think those 2 param() statements are doing.
(This post was edited by FishMonger on Nov 3, 2012, 6:52 AM)