Hi there, JPDeni.
I guess I'm still not getting it.
The code I have in my db.cgi matches what you showed in the sample, except I found that I had to put a "}" before the "(length($in{$col}) > $db_lengths{$col}) and" line, otherwise I got an Internal Service Error.
Putting that } back in, if I leave say the Quarter ET field blank, I get the message:
"QuarterET not within acceptable range"
For any combination of leaving the FP fields blank, the error message is similar to the above, but with the appropriate fieldnames.
Let me post the code I've got. I'm probably missing something obvious...
<< from default.cfg>>
# Database Definition
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Name => [1, 'alpha', 30, 255, 1, '', ''],
Nick => [2, 'alpha', 25, 255, 0, '', ''],
City => [3, 'alpha', 25, 255, 1, '', ''],
StateProv => [4, 'alpha', 0, 40, 1, '', ''],
Email => [5, 'alpha', 30, 255, 1, '', '.+\@.+\..+'],
WebPage => [6, 'alpha', 40, 255, 0, 'http://', '^http://'],
Car => [7, 'alpha', 0, 60, 1, '', ''],
Year => [8, 'alpha', 0, 60, 1, '', ''],
Colour => [9, 'alpha', 0, 22, 0, '', ''],
Performance => [10, 'alpha', '50x2', 500, 0, '', ''],
Handling => [11, 'alpha', '50x2', 500, 0, '', ''],
Appearance => [12, 'alpha', '50x2', 500, 0, '', ''],
Audio => [13, 'alpha', '50x2', 500, 0, '', ''],
Misc => [14, 'alpha', '50x2', 500, 0, '', ''],
QuarterET => [15, 'numer', 5, 8, 0, '', ''],
QuarterMPH => [16, 'numer', 5, 8, 0, '', ''],
Quarter60 => [17, 'numer', 5, 8, 0, '', ''],
Pics => [18, 'alpha', 40, 255, 0, 'http://', '^http://'],
DateSubmit => [19, 'date', 12, 15, 1, &get_date, ''],
DateMod => [20, 'date', 12, 15, 1, &get_date, ''],
Userid => [21, 'alpha', -2, 15, 0, '', '']
);
<<from html.pl>>
print qq|
<TABLE WIDTH="450" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
... other field definitions...
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Quarter ET:</FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="QuarterET" VALUE="$rec{'QuarterET'}" SIZE="6" MAXLENGTH="6"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Quarter MPH:</FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="QuarterMPH" VALUE="$rec{'QuarterMPH'}" SIZE="7" MAXLENGTH="7"></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font>Quarter 60':</FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Quarter60" VALUE="$rec{'Quarter60'}" SIZE="5" MAXLENGTH="5"></TD></TR>
</TABLE>
<<from db.cgi>>
foreach $col (@db_cols) {
if ($in{$col} =~ /^\s*$/) { # entry is null or only whitespace
($db_not_null{$col}) and # entry is not allowed to be null.
push(@input_err, "$col (Can not be left blank)"); # so let's add it as an error
}
else { # else entry is not null.
($db_valid_types{$col} && !($in{$col} =~ /$db_valid_types{$col}/)) and
push(@input_err, "$col (Invalid format)"); # but has failed validation.
}
(length($in{$col}) > $db_lengths{$col}) and
push (@input_err, "$col (Too long. Max length: $db_lengths{$col})");
if ($db_sort{$col} eq "date") {
push (@input_err, "$col (Invalid date format)") unless &date_to_unix($in{$col});
}
if ($col eq 'QuarterET') {
($in{'QuarterET'} < 10 or $in{'QuarterET'} > 19.999) and
push(@input_err, "$col not within acceptable range");
}
if ($col eq 'QuarterMPH') {
($in{'QuarterMPH'} < 70 or $in{'QuarterMPH'} > 129.999) and
push(@input_err, "$col not within acceptable range");
}
if ($col eq 'Quarter60') {
($in{'Quarter60'} < 1.500 or $in{'Quarter60'} > 2.999) and
push(@input_err, "$col not within acceptable range");
}
}
I really do appreciate whatever help you can provide on this. Once I get this part working, I only need to get the new account setup part done and I'll be set to roll out the db to my members.
thanks,
juan