I've got a reentrant cgi program, part of which is a form. When I error check the form to make sure all the required fields are filled in I'm using the fact that I can just call my CGI program again.
The rub comes if the user hasn't filled in all the required fields. After all required fields are filled in, the program moves to the next web page as it should, however it's concatenating the information in the field to the data that exists for the given field: e.g. if the name entered is Joe, it becomes JoeJoe. This is only happening on fields that were previously entered. If there are no errors, then all works as expected.
I tried using the override function on the fields but that returned "error" in the one field I tested it in. My next thought was to delete the paramters of the required fields that were filled in using $query->delete() but that doesn't make sense as a solution.
So my question is why is this happening? Has anyone else expereinced this happening? And, if so how did you fix it?
Update: Thanks to the other monks for pointing out I didn't provide enough information. I'd been fighting something I thought was fixed and banged this question out. Bad idea.
I'm using CGI.pm to do my form building and processing. Like I said above, I'm calling the same CGI script but using different subroutines depending on what parameters are passed through the submit.
On this particular section I'm trying to verify that all the required fields were filled in, and if not, the page is called again with the errant fields highlighted. All very simple.
print $query->br, $query->br, $query->br, $query->startform; --code snipped-- $query->TR( [ $query->td( { -class => "$bData{BillName}{value}" }, $query->font( { -size => '-1', -face => 'arial, helvetica' }, 'Name:' ) ) . $query->td( $query->textfield( -name => 'BillName', -value => '', -maxlength => 70, -size => 50, ) ) ] ), # end TR
is how I've set up my form. Obviously there are more fields, but until I tested for a blank field, I never realized that the form data is being concatenated to itself for every field.
I had changed the code to
$query->textfield( -name => 'BillName', -value => $query->param('BillName'), -maxlength => 70, -size => 50, )
however this places the word "-maxlength" in the field upon reentry.
As I said, using -override in the textfield placed the word "error" in the form when it was redrawn. My understanding of -override was that you could change the vaule in a field, but that's not the answer either.
Using Data::Dumper to dump the passed paramters is showing that every time a correction is made, all the information that was filled in before is concatenated to it's field, so that if the BillName field was Joe Bloe, then it's passing Joe BloeJoe Bloe if only one correction was done.
Hopefully I've made this understandable enough so that perhaps someone can spot my problem.
Update II: I've finally solved the problem!
In the middle of working on some error checking I had a line that passed all of the parameters back to the form in hidden fields, thereby duplicating all information contained in the form.
Since I was passing essentially two copies of the same parameter, when the code re-entered the subroutine, it was tacking on the hidden to the sticky, and hence the problem.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |