我一直无法找到解决此问题的方法,并希望另一双眼睛可能会发现一些东西。当第一个“if”不正确并且我不知道为什么时,不会执行 else $confirm = 行。
if($_POST['zip'] && $_POST['country']=='USA' && !empty($fax)){
$plus4 = substr($_POST["zip"],6,4);
if (empty($plus4)) {
$link = '<a href="http://zip4.usps.com/zip4/welcome.jsp?city='.$city.'&address2='.$address.'&state='.$state.'&zip5='.$zip.'" class="greybox" onclick="window.scrollTo(0,0)">Zip + 4</a>';
$msg = "Your Zip + 4 was not provided! We cannot fax your Representative without your Zip+4.<br/>Click here to find your ".$link ;
print "<p style=\"color: red;\"><b>$msg<br/><br/></b></p>";
}
if (empty($_POST['state']) || empty($_POST['zip'])) $statezip = false ; // Check for State & Zip Required
else $statezip = true ;
//if (empty($state) || empty($zip) || empty($plus4)) $statezip = false ; // Check for State & Zip Required
$confirm = !empty($_POST['name']) && !empty($_POST['from']) && !empty($_POST['address']) && !empty($_POST['city']) && !empty($_POST['country']) && $statezip == true ; // Verify required fields
}
else $confirm = !empty($_POST['name']) && !empty($_POST['from']) && !empty($address) && !empty($city) && !empty($country) && $statezip == true ; // Verify required fields