FWIW, the way I would do it involves rethinking the big picture.
- cleanse variables
- test conditions and take actions
- default output (form)
your function for cleansing variables, checkFieldAlpha(), could accept another boolean parameter, "$required field". That way if a variable is empty, it can set global $formComplete to false.
In step 2, check for what kind of submission it is, check your required variable flag, and take appropriate action. If you don't want the default output, just die; at the end of the condition.
pseudocode:
// init global variables
$formComplete = true;
// cleanse all user inputed variables
// assume that checkField...() sets $formComplete to false if no var value
checkFieldAlpha($_POST['usrfname'],true);
// woops, not sure how these fit in...
$_SESSION['cartid'] = GetCartId();
$_SESSION['table'] = $_GET['table']; // looks like a security issue...
$_SESSION['country'] = $_GET['country'];
// etc.
// now test results of user submission
// I'm assuming the actions are exclusive.
if($_POST['ordtype'] == "cc" && $formComplete){
// [cc action/output]
die;
}
if($_POST['ordtype'] == "phone" && $formComplete){
// [phone action/output]
die;
}
if($_POST['ordtype'] == "mail" && $formComplete){
// [mail action/output]
die;
}
// end of submission possibilities; display default form
?>
[form]
HTH