//include_once("topstuff.php");
function check_empty_fields($method = "post") {
global $req_fields, $msg;
$use_method = ($method == "post") ? $_POST : $_GET;
$errors = "";
$count_empty = 0;
foreach ($req_fields as $key => $val) {
$field_name = (array_key_exists($key, $req_fields)) ? $req_fields[$key] : $key;
if (!array_key_exists($key, $use_method) || empty($use_method[$key])) {
$_SESSION[$key] = true;
$errors .= "|".$field_name;
$count_empty++;
} else {
$_SESSION[$key] = false;
}
}
if ($count_empty == 0) {
return true;
} else {
$msg = "The following (required) fields are empty:";
$msg_parts = explode("|", ltrim($errors, "|"));
$num_parts = count($msg_parts);
$msg .= "";
for ($i = 0; $i < $num_parts; $i++) {
$msg .= $msg_parts[$i];
if ($i <= $num_parts - 2) {
$msg .= ($i == $num_parts - 2) ? " & " : ", ";
}
}
$msg .= "\n";
return false;
}
}
if ($buyFName == "") {
echo "
You forgot to tell me your FIRST NAME. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($buyLName == "") {
echo "You forgot to tell me your LAST NAME. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($buyAddA == "") {
echo "You forgot to tell me your ADDRESS. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($buyCity == "") {
echo "You forgot to tell me your CITY or TOWN. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if($buyCountry=='United States'){
if ($buyState == "") {
echo "You forgot to tell me your STATE or PROVINCE. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($buyZip == "") {
echo "You forgot to tell me your ZIP or POSTAL CODE. Please scroll down and complete the order form.";
require_once("userinput.php");
}
}
if ($buyEmail == "") {
echo "You forgot to tell me your E-MAIL ADDRESS. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($buyPhone == "") {
echo "You forgot to tell me your PHONE NUMBER. Please scroll down and complete the order form.";
require_once("userinput.php");
}
// ============================================== Ship To Errors =======================
if ($shipFName == "") {
echo "You forgot to tell me the FIRST NAME to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($shipLName == "") {
echo "You forgot to tell me the LAST NAME to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($shipAddA == "") {
echo "You forgot to tell me the ADDRESS to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($shipCity == "") {
echo "You forgot to tell me the CITY or TOWN to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if($shipCountry=='United States'){ // --------- US conditional
if ($shipState == "") {
echo "You forgot to tell me the STATE or PROVINCE to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($shipZip == "") {
echo "You forgot to tell me the ZIP or POSTAL CODE to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
/*
//--------------Check if zipcode is in state
if($shipZip){
// echo $shipZip;
$checkzip=substr($shipZip,0,5);
$result1=mysql("zipcodes","Select state from zips where zip='$checkzip'");
while ($row = mysql_fetch_row($result1)) {
$ABB=$row[0];
// echo "$ABB";
}
$result2=mysql("htfbCart","SELECT stateName from state2abb where state='$ABB'");
while ($row2 = mysql_fetch_row($result2)) {
$stateName=$row2[0];
}
if (
strcasecmp($stateName, $shipState) != 0 && // if not full name match
strcasecmp($shipState,$ABB)!=0 && // if not abbreviation match
!eregi($shipState, $stateName) // if not short version
) {
mail("bizshop@bizshop.com","ZipCode mismatch","$ABB shipState $shipState stateName $stateName Zip $shipZip");
//echo "$ABB shipState $shipState stateName $stateName";
//echo "
The ship to Zip you entered does not match the ship to State (entered. Please scroll down and correct the order form.";
//$shipZip="$shipZip\" style=\"color:blue; background-color:yellow; border-width: 5px; border-color:red\" ";
//require_once("userinput.php");
//exit;
}}
*/
} // ----------------- end of US conditional
if ($shipEmail == "") {
echo "You forgot to tell me the E-MAIL ADDRESS to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
if ($shipPhone == "") {
echo "You forgot to tell me the PHONE NUMBER to ship to. Please scroll down and complete the order form.";
require_once("userinput.php");
}
## if ($PayMethod == "Credit" AND $CCType == "") {
## Brand();
## require("masthead");
## commonHeader("$Company","Oops...");
## echo "You forgot to tell me the CREDIT CARD TYPE. Please scroll down and complete the order form.");
## commonFooter($Relative,$UserID);
## exit;
## }
##
##
## if ($PayMethod == "Credit" AND $CCNum == "") {
## Brand();
## require("masthead");
## commonHeader("$Company","Oops...");
## echo "You forgot to tell me the CREDIT CARD NUMBER. Please scroll down and complete the order form.");
## commonFooter($Relative,$UserID);
## exit;
## }
## if ($PayMethod == "Credit" AND $CCExpire == "") {
## Brand();
## require("masthead");
## commonHeader("$Company","Oops...");
## echo "You forgot to tell me the CREDIT CARD EXPIRATION DATE. Please scroll down and complete the order form.");
## commonFooter($Relative,$UserID);
## exit;
## }
?>