Howdy all
I'm writing a script which will create a form, untaint submitted data and return error messages to the user when their input is not what was expected. It should then show them the form again, remembering the values which were good, but clearing the textfields it didn't like, as well as pointing the user to the fields which need to be filled in again. I am having no problem untainting or remembering the data, but am encountering a really weird bug when it comes to emptying the fields. I'm using self_url() to refer the script back to itself and hence remember the data that was good, and when the script encounters an input value that doesn't match what it was expecting, it pushes the name of that parameter into an array. When it has checked all the data, it iterates through the array passing each value to $query->delete($name_of_field) which should mean that all the fields the script didn't like come back blank next time round. However, the results are....interesting to say the least. The parameter are being pushed into the array correctly, but only some of the fields are coming back clear (always the same ones each time and indepedent of what the fields should contain or the order in which they were pushed into the array). The script itself doesn't ever seem to think it is able to delete any of the values.
#An example of the untainting code for a value not being deleted: if (param('house') =~ /^([\dA-Za-z '-]{1,20})$/ ) { $house = $1; } else { push @problem, "House name or number"; push @delete, "house"; } #And one that is: if (param('email1') =~ /^(([\w\.]{1,40})@([\w\.]{1,30}))$/ ) { $email = $1; } else { push @problem, "e-mail address"; push @delete, "email1"; } #I'm aware that this will disallow some valid e-mail addresses, but I' +m not worrying about that for the moment #And the code that should delete all the invalid input: my $i; foreach $i (@delete) { $query->delete($i); }
I would really appreciate any suggestions asI've been banging my head against a brick wall with this all afternoon and it's probably something very easy that I'm overlooking :)
In reply to Deleting submitted values from and HTML form by Nevtlathiel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |