Code: Select all
[color=#0000FF]if($_POST['[/color][color=#FF0000]field1[/color][color=#0000FF]'] == NULL){
$reqerrors[] = "Yes";
$cholesterolerror = "\t<br><span class=pred>You must enter a value.</span>\n";
}
elseif(is_numeric($_POST['[/color][color=#FF0000]field1[/color][color=#0000FF]']) && $_POST['[/color][color=#FF0000]field1[/color][color=#0000FF]'] >= 0) {
}
else {
$reqverrors[] = "Yes";
$[/color][color=#FF0000]field1[/color][color=#0000FF]= "\t<br><span class=pred>Invalid value entered.</span>\n";
}[/color]Problem is, I have about 20 more fields that I would like to apply the above validation code. For maintanability sake, there has to be a slick way to make the above in blue a function, that I can apply like so:
function(field1)
function(field2)
function(field3)