When facing code like this, I often find that the problem pops right out when I do a little refactoring. I'd start by breaking out two separate subroutines, along the lines of:
Right away, this breaks the problem down into smaller pieces. Then, I'd rewire logic in handleSubmit to handle the error cases first as "guard clauses". Something like:if ( param('Submit') ) { handleSubmit(); } else { emitForm(); }
At this point, I'd have an "oh shit" moment, and would arrange to turn on taint-checking and add code to validate $email to ensure that someone isn't sneaking in an exploit, but that's really a separate issue.if ( $name eq "" ) { print "<font color=red>Blah blah blah.</font>"; return; } if ( $email eq "" ) { print "<font color=red>Blah blah blah.</font>"; return; } ... open(MAIL, "|$sendmail -t") or die "Cannot access mail"; print MAIL "To: $adminmail\n"; print MAIL "From: $email\n"; ...
Try this approach, and see if you can't figure the problem out yourself.
In reply to Re: Form problems
by dws
in thread Form problems
by sulfericacid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |