You'll need to look at all your $vald_* variables to see if they're set or not in order to decide whether or not their respective tests failed. That would make for an ugly test at the end.
Here's a bitfield solution (not necessarily the best, but a lot more convenient than a lot of plain variables that may or may not even be set).
define('INVALID_USER_NAME', 1);
define('INVALID_USER_PASSWORD', 2);
define('INVALID_TXTCONFIRM', 4);
define('INVALID_PASSWORDMATCH', 8);
define('INVALID_USER_EMAIL', 16);
define('INVALID_USER_AGREEMENT', 32);
/***** Validate Sign-Up Form *****/
$tests = 0;
if (!preg_match($regex_lettersnumbersunderscore, $fv_user_name)) {
$tests |= INVALID_USER_NAME;
}
if (!preg_match($regex_lettersnumbersunderscore, $fv_user_password)) {
$tests |= INVALID_USER_PASSWORD;
}
if (!preg_match($regex_lettersnumbersunderscore, $fv_txtconfirm)) {
$tests |= INVALID_TXTCONFIRM;
}
if ("$fv_user_password" != "$fv_txtconfirm") {
$test |= INVALID_PASSWORDMATCH;
}
if (!preg_match($regex_email, $fv_user_email)) {
$test |= INVALID_USER_EMAIL;
}
if (!preg_match($regex_capitalY, $fv_user_agreement)) {
$test |= INVALID_USER_AGREEMENT;
}
if($test==0)
{
$vald_form1 = "P";
}
And you can see which tests failed by using, e.g.,
if($tests&INVALID_USER_EMAIL)
{ // Email was invalid
}