Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Create_Account - Empty fields warnings


bigbird_3156

Recommended Posts

Posted

Hi,

 

Ive been playing around with my create_account.php file to change the layout to make it more friendly for a wholesaler based site....

 

I have added the Modules Separate Price Per Customer and Advance Address Management to my site which seemed to work fine before I changed the layout of the create_account.php page...

 

When I changed the layout, and then click on the create new account in the customer section I get a list of all those pink warnings at the top of the page as if I have tried to submit a blank form - even though I have not.

 

The page works fine besides that, but it looks very unprofessional.... can anyone see what I did wrong??? - file below;

 

<?php
/*
 $Id$
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 osCommerce
 Released under the GNU General Public License
*/
ini_set('mbstring.internal_encoding','UTF-8');
ini_set( 'default_charset', 'UTF-8' );
 require('includes/application_top.php');
// needs to be included earlier to set the success message in the messageStack
 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT);
   function format_US_Canada_phone($phone) {
  $temp = '';
  for ($x = 0; $x < strlen($phone); $x++) { // strip non-digits
    $c = substr($phone, $x, 1);
    if (($c >= '0') && ($c <= '9')) $temp .= $c;
  }
  if (substr($temp, 0, 1) == '1') $temp = substr($temp, 1); // strip leading 1, long distance indicator
  if (strlen($temp) == 7)  // phone number without area code
	  return substr($temp, 0, 3) . '-' . substr($temp, 3);
  if (strlen($temp) < 10) return false; // phone number too short
  if (strlen($temp) > 10) { // phone number includes extension
    return '(' . substr($temp, 0, 3) . ') ' . substr($temp, 3, 3) . '-' . substr($temp, 6, 4) . ' ext. ' . substr($temp, 10);
  } else { // standard phone number with area code
    return '(' . substr($temp, 0, 3) . ') ' . substr($temp, 3, 3) . '-' . substr($temp, 6, 4);
  }
   }
 // load countries and states, used for both entry form and validations
 $cl = $country_info = array();
 $countries_array = array(array('id' => 'not_selected', 'text' => PULL_DOWN_DEFAULT));
 $countries_query = tep_db_query("select * from " . TABLE_COUNTRIES . " order by countries_name");
 while ($country = tep_db_fetch_array($countries_query)) {
   $cl[] = $country['countries_id']; // list of country ids for javascript and loops
   $country_info[$country['countries_id']] = $country; // used in validations
   $countries_array[] = array('id' => $country['countries_id'], 'text' => $country['countries_name']); // for country pulldown menus
 }
 if (ACCOUNT_STATE == 'true') {
   $allzones = $checkzones = $zonenames = array();
   foreach ($cl as $id) {
  $zones_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
  $zones_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$id . "' order by zone_name");
  if (tep_db_num_rows($zones_query) == 0) {
    $allzones[$id] = false; // save note that this country has no zones
  } else { // otherwise create list of zones
    while ($zones_values = tep_db_fetch_array($zones_query)) {
	  $zones_array[] = array('id' => $zones_values['zone_id'], 'text' => $zones_values['zone_name']);
	  $checkzones[$id][] = $zones_values['zone_id']; // used in validations
	  $zonenames[$id][$zones_values['zone_id']] = $zones_values['zone_name'];
    }
    $allzones[$id] = $zones_array; // save this country's state array
  }
   }
 }

 $process = false;
 if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken)) {
   $process = true;
   if (ACCOUNT_GENDER == 'true') {
  if (isset($HTTP_POST_VARS['gender'])) {
    $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
  } else {
    $gender = false;
  }
   }
   $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
   if ((strcmp($firstname, mb_strtoupper($firstname, 'UTF-8')) == 0)) $firstname = mb_strtolower($firstname, 'UTF-8');
   if ((strcmp($firstname, mb_strtolower($firstname, 'UTF-8')) == 0)) $firstname = mb_convert_case($firstname, MB_CASE_TITLE, 'UTF-8');
   $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
   if ((strcmp($lastname, mb_strtoupper($lastname, 'UTF-8')) == 0)) $lastname = mb_strtolower($lastname, 'UTF-8');
   if ((strcmp($lastname, mb_strtolower($lastname, 'UTF-8')) == 0)) $lastname = mb_convert_case($lastname, MB_CASE_TITLE, 'UTF-8');
   if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);
   $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
   if ((strcmp($email_address, mb_strtoupper($email_address, 'UTF-8')) == 0)) $email_address = mb_strtolower($email_address, 'UTF-8');
   $confirm_email_address = tep_db_prepare_input($HTTP_POST_VARS['confirm_email_address']);
   if ((strcmp($confirm_email_address, mb_strtoupper($confirm_email_address, 'UTF-8')) == 0)) $confirm_email_address = mb_strtolower($confirm_email_address, 'UTF-8');

// BOF Separate Pricing Per Customer, added: field for tax id number
   if (ACCOUNT_COMPANY == 'true') {
  $company = tep_db_prepare_input($_POST['company']);
  $company_tax_id = tep_db_prepare_input($_POST['company_tax_id']);
   }
// EOF Separate Pricing Per Customer, added: field for tax id number

//    if (ACCOUNT_COMPANY == 'true') {
//	  $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
  if ((strcmp($company, mb_strtoupper($company, 'UTF-8')) == 0)) $company = mb_strtolower($company, 'UTF-8');
  if ((strcmp($company, mb_strtolower($company, 'UTF-8')) == 0)) $company = mb_convert_case($company, MB_CASE_TITLE, 'UTF-8');
   }
   $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
   if ((strcmp($street_address, mb_strtoupper($street_address, 'UTF-8')) == 0)) $street_address = mb_strtolower($street_address, 'UTF-8');
   if ((strcmp($street_address, mb_strtolower($street_address, 'UTF-8')) == 0)) $street_address = mb_convert_case($street_address, MB_CASE_TITLE, 'UTF-8');
   $address2 = tep_db_prepare_input($HTTP_POST_VARS['address2']);
   if ((strcmp($address2, mb_strtoupper($address2, 'UTF-8')) == 0)) $address2 = mb_strtolower($address2, 'UTF-8');
   if ((strcmp($address2, mb_strtolower($address2, 'UTF-8')) == 0)) $address2 = mb_convert_case($address2, MB_CASE_TITLE, 'UTF-8');
   if (ACCOUNT_SUBURB == 'true') {
  $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
  if ((strcmp($suburb, mb_strtoupper($suburb, 'UTF-8')) == 0)) $suburb = mb_strtolower($suburb, 'UTF-8');
  if ((strcmp($suburb, mb_strtolower($suburb, 'UTF-8')) == 0)) $suburb = mb_convert_case($suburb, MB_CASE_TITLE, 'UTF-8');
   }
   $postcode = strtoupper(tep_db_prepare_input($HTTP_POST_VARS['postcode']));
   $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
   if ((strcmp($city, mb_strtoupper($city, 'UTF-8')) == 0)) $city = mb_strtolower($city, 'UTF-8');
   if ((strcmp($city, mb_strtolower($city, 'UTF-8')) == 0)) $city = mb_convert_case($city, MB_CASE_TITLE, 'UTF-8');
   if (ACCOUNT_STATE == 'true') {
  if (isset($HTTP_POST_VARS['state'])) {
    $state = tep_db_prepare_input($HTTP_POST_VARS['state']);
    if ((strcmp($state, mb_strtoupper($state, 'UTF-8')) == 0)) $state = mb_strtolower($state, 'UTF-8');
    if ((strcmp($state, mb_strtolower($state, 'UTF-8')) == 0)) $state = mb_convert_case($state, MB_CASE_TITLE, 'UTF-8');
  } else {
    $state = '';
  }
  if (isset($HTTP_POST_VARS['zone_id'])) {
    $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
  } else {
    $zone_id = '';
  }
   }
   $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
   $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);
   $alt_phone = tep_db_prepare_input($HTTP_POST_VARS['alternate_telephone']);
   $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);
   if (isset($HTTP_POST_VARS['newsletter'])) {
  $newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);
   } else {
  $newsletter = false;
   }
   $password = tep_db_prepare_input($HTTP_POST_VARS['password']);
   $confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);
   $error = false;
   // validate mailing address
   if (ACCOUNT_GENDER == 'true') {
  if ( ($gender != 'm') && ($gender != 'f') ) {
    $error = true;
    $messageStack->add('create_account', ENTRY_GENDER_ERROR);
  }
   }
   if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', ENTRY_FIRST_NAME_ERROR);
   }
   if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', ENTRY_LAST_NAME_ERROR);
   }
   if (ACCOUNT_DOB == 'true') {
  if ((strlen($dob) < ENTRY_DOB_MIN_LENGTH) || (!empty($dob) && (!is_numeric(tep_date_raw($dob)) || !@checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4))))) {
    $error = true;
    $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
  }
   }
   if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR);
   } elseif (tep_validate_email($email_address) == false) {
  $error = true;
  $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
   } else {
  $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
  $check_email = tep_db_fetch_array($check_email_query);
  if ($check_email['total'] > 0) {
    $error = true;
    $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
  }
   }
if (ACCOUNT_COMPANY == 'true') {
  if ( (strlen($company) == 0) && (strlen($company) < ENTRY_COMPANY_MIN_LENGTH) ) {
	  $error = true;
	  $messageStack->add('create_account', ENTRY_COMPANY_ERROR);
  }
 }
   if (strcasecmp($email_address, $confirm_email_address) != 0) {
  $error = true;
  $messageStack->add('create_account', ENTRY_ERROR_EMAIL_MATCH);
   }
   if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', TEXT_MAILING . ENTRY_STREET_ADDRESS_ERROR);
   }
   if (tep_not_null($country_info[$country]['countries_postal_validation'])) {
  if (!preg_match($country_info[$country]['countries_postal_validation'], $postcode)) {
    $error = true;
    $messageStack->add('create_account', TEXT_MAILING . sprintf(ENTRY_ERROR_POSTCODE, strtolower($country_info[$country]['countries_iso_code_3']), $country_info[$country]['countries_name']));
  }
   }
   if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', TEXT_MAILING . ENTRY_CITY_ERROR);
   }
   if (!is_numeric($country) || !in_array($country, $cl)) {
  $error = true;
  $messageStack->add('create_account', TEXT_MAILING . ENTRY_COUNTRY_ERROR);
   }
   if (ACCOUNT_STATE == 'true') {
  if (is_array($allzones[$country])) {
    if (tep_not_null($zone_id) && in_array($zone_id, $checkzones[$country])) {
	  $state = $zonenames[$country][$zone_id];
    } elseif ($country_info[$country]['requires_state'] == 1) {
	  $error = true;
	  $messageStack->add('create_account', TEXT_MAILING . ENTRY_STATE_ERROR_SELECT);
    }
  } else {
    if (($country_info[$country]['requires_state'] == 1) && (strlen($state) < ENTRY_STATE_MIN_LENGTH)) {
	  $error = true;
	  $messageStack->add('create_account', TEXT_MAILING . ENTRY_STATE_ERROR);
    }
  }
   }
   if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR);
   }
   if (($country_info[$country]['countries_iso_code_2'] == 'US') || ($country_info[$country]['countries_iso_code_2'] == 'CA')) { // format US/Canada phone numbers
  $telephone = format_US_Canada_phone($telephone);
  if ($telephone === false) {
    $error = true;
    $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER . ENTRY_ERROR_US_CANADA_PHONE);
  }
  if (strlen($alt_phone) > 0) $alt_phone = format_US_Canada_phone($alt_phone);
  if ($alt_phone === false) {
    $error = true;
    $messageStack->add('create_account', ENTRY_ALTERNATE_TELEPHONE . ENTRY_ERROR_US_CANADA_PHONE);
  }
  if (strlen($fax) > 0) $fax = format_US_Canada_phone($fax);
  if ($fax === false) {
    $error = true;
    $messageStack->add('create_account', ENTRY_FAX_NUMBER . ENTRY_ERROR_US_CANADA_PHONE);
  }
   }
   if ($alt_phone == $telephone) $alt_phone = ''; // dispose of duplicate phone number
   if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
  $error = true;
  $messageStack->add('create_account', ENTRY_PASSWORD_ERROR);
   } elseif ($password != $confirmation) {
  $error = true;
  $messageStack->add('create_account', ENTRY_PASSWORD_ERROR_NOT_MATCHING);
   }
   // process billing address
   if (isset($HTTP_POST_VARS['billing_is_mailing'])) {
  $billing_is_mailing = tep_db_prepare_input($HTTP_POST_VARS['billing_is_mailing']);
  if ($billing_is_mailing != 'Y') $billing_is_mailing = 'N';
   } else {
  $billing_is_mailing = 'N';
   }
   if ($billing_is_mailing == 'N') { // process only if billing address is not the same as mailing address
  if (ACCOUNT_GENDER == 'true') {
    if (isset($HTTP_POST_VARS['billing_gender'])) {
	  $billing_gender = tep_db_prepare_input($HTTP_POST_VARS['billing_gender']);
    } else {
	  $billing_gender = false;
    }
  }
  $billing_firstname = tep_db_prepare_input($HTTP_POST_VARS['billing_firstname']);
  if ((strcmp($billing_firstname, mb_strtoupper($billing_firstname, 'UTF-8')) == 0)) $billing_firstname = mb_strtolower($billing_firstname, 'UTF-8');
  if ((strcmp($billing_firstname, mb_strtolower($billing_firstname, 'UTF-8')) == 0)) $billing_firstname = mb_convert_case($billing_firstname, MB_CASE_TITLE, 'UTF-8');
  $billing_lastname = tep_db_prepare_input($HTTP_POST_VARS['billing_lastname']);
  if ((strcmp($billing_lastname, mb_strtoupper($billing_lastname, 'UTF-8')) == 0)) $billing_lastname = mb_strtolower($billing_lastname, 'UTF-8');
  if ((strcmp($billing_lastname, mb_strtolower($billing_lastname, 'UTF-8')) == 0)) $billing_lastname = mb_convert_case($billing_lastname, MB_CASE_TITLE, 'UTF-8');
  if (ACCOUNT_COMPANY == 'true') {
    $billing_company = tep_db_prepare_input($HTTP_POST_VARS['billing_company']);
    if ((strcmp($billing_company, mb_strtoupper($billing_company, 'UTF-8')) == 0)) $billing_company = mb_strtolower($billing_company, 'UTF-8');
    if ((strcmp($billing_company, mb_strtolower($billing_company, 'UTF-8')) == 0)) $billing_company = mb_convert_case($billing_company, MB_CASE_TITLE, 'UTF-8');
  }
  $billing_street_address = tep_db_prepare_input($HTTP_POST_VARS['billing_street_address']);
  if ((strcmp($billing_street_address, mb_strtoupper($billing_street_address, 'UTF-8')) == 0)) $billing_street_address = mb_strtolower($billing_street_address, 'UTF-8');
  if ((strcmp($billing_street_address, mb_strtolower($billing_street_address, 'UTF-8')) == 0)) $billing_street_address = mb_convert_case($billing_street_address, MB_CASE_TITLE, 'UTF-8');
  $billing_address2 = tep_db_prepare_input($HTTP_POST_VARS['billing_address2']);
  if ((strcmp($billing_address2, mb_strtoupper($billing_address2, 'UTF-8')) == 0)) $billing_address2 = mb_strtolower($billing_address2, 'UTF-8');
  if ((strcmp($billing_address2, mb_strtolower($billing_address2, 'UTF-8')) == 0)) $billing_address2 = mb_convert_case($billing_address2, MB_CASE_TITLE, 'UTF-8');
  if (ACCOUNT_SUBURB == 'true') {
    $billing_suburb = tep_db_prepare_input($HTTP_POST_VARS['billing_suburb']);
    if ((strcmp($billing_suburb, mb_strtoupper($billing_suburb, 'UTF-8')) == 0)) $billing_suburb = mb_strtolower($billing_suburb, 'UTF-8');
    if ((strcmp($billing_suburb, mb_strtolower($billing_suburb, 'UTF-8')) == 0)) $billing_suburb = mb_convert_case($billing_suburb, MB_CASE_TITLE, 'UTF-8');
  }
  $billing_postcode = strtoupper(tep_db_prepare_input($HTTP_POST_VARS['billing_postcode']));
  $billing_city = tep_db_prepare_input($HTTP_POST_VARS['billing_city']);
  if ((strcmp($billing_city, mb_strtoupper($billing_city, 'UTF-8')) == 0)) $billing_city = mb_strtolower($billing_city, 'UTF-8');
  if ((strcmp($billing_city, mb_strtolower($billing_city, 'UTF-8')) == 0)) $billing_city = mb_convert_case($billing_city, MB_CASE_TITLE, 'UTF-8');
  if (ACCOUNT_STATE == 'true') {
    if (isset($HTTP_POST_VARS['billing_state'])) {
	  $billing_state = tep_db_prepare_input($HTTP_POST_VARS['billing_state']);
	  if ((strcmp($billing_state, mb_strtoupper($billing_state, 'UTF-8')) == 0)) $billing_state = mb_strtolower($billing_state, 'UTF-8');
	  if ((strcmp($billing_state, mb_strtolower($billing_state, 'UTF-8')) == 0)) $billing_state = mb_convert_case($billing_state, MB_CASE_TITLE, 'UTF-8');
    } else {
	  $billing_state = '';
    }
    if (isset($HTTP_POST_VARS['billing_zone_id'])) {
	  $billing_zone_id = tep_db_prepare_input($HTTP_POST_VARS['billing_zone_id']);
    } else {
	  $billing_zone_id = '';
    }
  }
  $billing_country = tep_db_prepare_input($HTTP_POST_VARS['billing_country']);
  // validate billing address information
  if (ACCOUNT_GENDER == 'true') {
    if ( ($billing_gender != 'm') && ($billing_gender != 'f') ) {
	  $error = true;
	  $messageStack->add('create_account', TEXT_BILLING . ENTRY_GENDER_ERROR);
    }
  }
  if (strlen($billing_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_BILLING . ENTRY_FIRST_NAME_ERROR);
  }
  if (strlen($billing_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_BILLING . ENTRY_LAST_NAME_ERROR);
  }
  if (strlen($billing_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_BILLING . ENTRY_STREET_ADDRESS_ERROR);
  }
  if (tep_not_null($country_info[$billing_country]['countries_postal_validation'])) {
    if (!preg_match($country_info[$billing_country]['countries_postal_validation'], $billing_postcode)) {
	  $error = true;
	  $messageStack->add('create_account', TEXT_BILLING . sprintf(ENTRY_ERROR_POSTCODE, strtolower($country_info[$billing_country]['countries_iso_code_3']), $country_info[$billing_country]['countries_name']));
    }
  }
  if (strlen($billing_city) < ENTRY_CITY_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_BILLING . ENTRY_CITY_ERROR);
  }
  if (!is_numeric($billing_country) || !in_array($billing_country, $cl)) {
    $error = true;
    $messageStack->add('create_account', TEXT_BILLING . ENTRY_COUNTRY_ERROR);
  }
  if (ACCOUNT_STATE == 'true') {
    if (is_array($allzones[$billing_country])) { // country has zones set in database, retrieve state name from database using zone_id
	  if (tep_not_null($billing_zone_id) && in_array($billing_zone_id, $checkzones[$billing_country])) {
	    $billing_state = $zonenames[$billing_country][$billing_zone_id];
	  } elseif ($country_info[$billing_country]['requires_state'] == 1) { // if no state found to match zone_id in country and country requires states
	    $error = true;
	    $messageStack->add('create_account', TEXT_BILLING . ENTRY_STATE_ERROR_SELECT);
	  }	 
    } else {
	  if (($country_info[$billing_country]['requires_state'] == 1) && (strlen($billing_state) < ENTRY_STATE_MIN_LENGTH)) {
	    $error = true;
	    $messageStack->add('create_account', TEXT_BILLING . ENTRY_STATE_ERROR);
	  }
    }
  }
   } // end process billing address
   // process shipping address
   if (isset($HTTP_POST_VARS['shipping_is_other'])) {
  $shipping_is_other = tep_db_prepare_input($HTTP_POST_VARS['shipping_is_other']);
  if (($shipping_is_other != 'M') && ($shipping_is_other != 'B')) $shipping_is_other = 'S';
   } else {
  $shipping_is_other = 'S';
   }
   if ($shipping_is_other == 'S') { // process only if shipping address is not the same as mailing or billing address
  if (ACCOUNT_GENDER == 'true') {
    if (isset($HTTP_POST_VARS['shipping_gender'])) {
	  $shipping_gender = tep_db_prepare_input($HTTP_POST_VARS['shipping_gender']);
    } else {
	  $shipping_gender = false;
    }
  }
  $shipping_firstname = tep_db_prepare_input($HTTP_POST_VARS['shipping_firstname']);
  if ((strcmp($shipping_firstname, mb_strtoupper($shipping_firstname, 'UTF-8')) == 0)) $shipping_firstname = mb_strtolower($shipping_firstname, 'UTF-8');
  if ((strcmp($shipping_firstname, mb_strtolower($shipping_firstname, 'UTF-8')) == 0)) $shipping_firstname = mb_convert_case($shipping_firstname, MB_CASE_TITLE, 'UTF-8');
  $shipping_lastname = tep_db_prepare_input($HTTP_POST_VARS['shipping_lastname']);
  if ((strcmp($shipping_lastname, mb_strtoupper($shipping_lastname, 'UTF-8')) == 0)) $shipping_lastname = mb_strtolower($shipping_lastname, 'UTF-8');
  if ((strcmp($shipping_lastname, mb_strtolower($shipping_lastname, 'UTF-8')) == 0)) $shipping_lastname = mb_convert_case($shipping_lastname, MB_CASE_TITLE, 'UTF-8');
  if (ACCOUNT_COMPANY == 'true') {
    $shipping_company = tep_db_prepare_input($HTTP_POST_VARS['shipping_company']);
    if ((strcmp($shipping_company, mb_strtoupper($shipping_company, 'UTF-8')) == 0)) $shipping_company = mb_strtolower($shipping_company, 'UTF-8');
    if ((strcmp($shipping_company, mb_strtolower($shipping_company, 'UTF-8')) == 0)) $shipping_company = mb_convert_case($shipping_company, MB_CASE_TITLE, 'UTF-8');
  }
  $shipping_street_address = tep_db_prepare_input($HTTP_POST_VARS['shipping_street_address']);
  if ((strcmp($shipping_street_address, mb_strtoupper($shipping_street_address, 'UTF-8')) == 0)) $shipping_street_address = mb_strtolower($shipping_street_address, 'UTF-8');
  if ((strcmp($shipping_street_address, mb_strtolower($shipping_street_address, 'UTF-8')) == 0)) $shipping_street_address = mb_convert_case($shipping_street_address, MB_CASE_TITLE, 'UTF-8');
  $shipping_address2 = tep_db_prepare_input($HTTP_POST_VARS['shipping_address2']);
  if ((strcmp($shipping_address2, mb_strtoupper($shipping_address2, 'UTF-8')) == 0)) $shipping_address2 = mb_strtolower($shipping_address2, 'UTF-8');
  if ((strcmp($shipping_address2, mb_strtolower($shipping_address2, 'UTF-8')) == 0)) $shipping_address2 = mb_convert_case($shipping_address2, MB_CASE_TITLE, 'UTF-8');
  if (ACCOUNT_SUBURB == 'true') {
    $shipping_suburb = tep_db_prepare_input($HTTP_POST_VARS['shipping_suburb']);
    if ((strcmp($shipping_suburb, mb_strtoupper($shipping_suburb, 'UTF-8')) == 0)) $shipping_suburb = mb_strtolower($shipping_suburb, 'UTF-8');
    if ((strcmp($shipping_suburb, mb_strtolower($shipping_suburb, 'UTF-8')) == 0)) $shipping_suburb = mb_convert_case($shipping_suburb, MB_CASE_TITLE, 'UTF-8');
  }
  $shipping_postcode = strtoupper(tep_db_prepare_input($HTTP_POST_VARS['shipping_postcode']));
  $shipping_city = tep_db_prepare_input($HTTP_POST_VARS['shipping_city']);
  if ((strcmp($shipping_city, mb_strtoupper($shipping_city, 'UTF-8')) == 0)) $shipping_city = mb_strtolower($shipping_city, 'UTF-8');
  if ((strcmp($shipping_city, mb_strtolower($shipping_city, 'UTF-8')) == 0)) $shipping_city = mb_convert_case($shipping_city, MB_CASE_TITLE, 'UTF-8');
  if (ACCOUNT_STATE == 'true') {
    if (isset($HTTP_POST_VARS['shipping_state'])) {
	  $shipping_state = tep_db_prepare_input($HTTP_POST_VARS['shipping_state']);
	  if ((strcmp($shipping_state, mb_strtoupper($shipping_state, 'UTF-8')) == 0)) $shipping_state = mb_strtolower($shipping_state, 'UTF-8');
	  if ((strcmp($shipping_state, mb_strtolower($shipping_state, 'UTF-8')) == 0)) $shipping_state = mb_convert_case($shipping_state, MB_CASE_TITLE, 'UTF-8');
    } else {
	  $shipping_state = '';
    }
    if (isset($HTTP_POST_VARS['shipping_zone_id'])) {
	  $shipping_zone_id = tep_db_prepare_input($HTTP_POST_VARS['shipping_zone_id']);
    } else {
	  $shipping_zone_id = '';
    }
  }
  $shipping_country = tep_db_prepare_input($HTTP_POST_VARS['shipping_country']);
  // validate shipping address information
  if (ACCOUNT_GENDER == 'true') {
    if ( ($shipping_gender != 'm') && ($shipping_gender != 'f') ) {
	  $error = true;
	  $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_GENDER_ERROR);
    }
  }
  if (strlen($shipping_firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_FIRST_NAME_ERROR);
  }
  if (strlen($shipping_lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_LAST_NAME_ERROR);
  }
  if (strlen($shipping_street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_STREET_ADDRESS_ERROR);
  }
  if (tep_not_null($country_info[$shipping_country]['countries_postal_validation'])) {
    if (!preg_match($country_info[$shipping_country]['countries_postal_validation'], $shipping_postcode)) {
	  $error = true;
	  $messageStack->add('create_account', TEXT_SHIPPING . sprintf(ENTRY_ERROR_POSTCODE, strtolower($country_info[$shipping_country]['countries_iso_code_3']), $country_info[$shipping_country]['countries_name']));
    }
  }
  if (strlen($shipping_city) < ENTRY_CITY_MIN_LENGTH) {
    $error = true;
    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_CITY_ERROR);
  }
  if (!is_numeric($shipping_country) || !in_array($shipping_country, $cl)) {
    $error = true;
    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_COUNTRY_ERROR);
  }
  if (ACCOUNT_STATE == 'true') {
    if (is_array($allzones[$shipping_country])) { // country has zones set in database, retrieve state name from database using zone_id
	  if (tep_not_null($shipping_zone_id) && in_array($shipping_zone_id, $checkzones[$shipping_country])) {
	    $shipping_state = $zonenames[$shipping_country][$shipping_zone_id];
	  } elseif ($country_info[$shipping_country]['requires_state'] == 1) { // if no state found to match zone_id in country and country requires states then there is an error
	    $error = true;
	    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_STATE_ERROR_SELECT);
	  }	 
    } else {
	  if (($country_info[$shipping_country]['requires_state'] == 1) && (strlen($shipping_state) < ENTRY_STATE_MIN_LENGTH)) {
	    $error = true;
	    $messageStack->add('create_account', TEXT_SHIPPING . ENTRY_STATE_ERROR);
	  }
    }
  }
   } // end process shipping address
   if ($error == false) {
  if (strlen($alt_phone) < 1) $alt_phone ='null';
  if (strlen($fax) < 1) $fax = 'null';
  $sql_data_array = array('customers_firstname' => $firstname,
						  'customers_lastname' => $lastname,
						  'customers_email_address' => $email_address,
						  'customers_telephone' => $telephone,
						  'customers_alternate_telephone' => (tep_not_null($alt_phone) ? $alt_phone : 'null'),
						  'customers_fax' => (tep_not_null($fax) ? $fax : 'null'),
						  'customers_newsletter' => $newsletter,
						  'customers_password' => tep_encrypt_password($password));
  if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
  if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);
// BOF Separate Pricing Per Customer
  // if you would like to have an alert in the admin section when either a company name has been entered in
  // the appropriate field or a tax id number, or both then uncomment the next line and comment the default
  // setting: only alert when a tax_id number has been given
  //    if ( (ACCOUNT_COMPANY == 'true' && tep_not_null($company) ) || (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) ) {
  if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id)  ) {
   $sql_data_array['customers_group_ra'] = '1';
// entry_company_tax_id moved from table address_book to table customers in version 4.2.0
   $sql_data_array['entry_company_tax_id'] = $company_tax_id;
  }
// EOF Separate Pricing Per Customer
  tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);
  $customer_id = tep_db_insert_id();
  $sql_data_array = array('customers_id' => $customer_id,
						  'entry_firstname' => $firstname,
						  'entry_lastname' => $lastname,
						  'entry_street_address' => $street_address,
						  'entry_address2' => (tep_not_null($address2) ? $address2 : 'null'),
						  'entry_postcode' => $postcode,
						  'entry_city' => $city,
						  'entry_country_id' => $country);
  if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;
  if ((ACCOUNT_COMPANY == 'true') && tep_not_null($company)) $sql_data_array['entry_company'] = $company;
  if ((ACCOUNT_SUBURB == 'true') && tep_not_null($suburb)) $sql_data_array['entry_suburb'] = $suburb;
  if (ACCOUNT_STATE == 'true') {
    if ($zone_id > 0) {
	  $sql_data_array['entry_zone_id'] = $zone_id;
    } else {
	  $sql_data_array['entry_zone_id'] = '0';
    }
    $sql_data_array['entry_state'] = (tep_not_null($state) ? $state : 'null');
  }
  tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
  $address_id = tep_db_insert_id();
  tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");
  tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int)$customer_id . "', '0', now())");
  if ($billing_is_mailing == 'Y') { // billing is same as mailing
    tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_billing_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");
    $billing_address_id = $address_id;
  } else { // billing is different than mailing so add billing address to database
    $sql_data_array = array('customers_id' => $customer_id,
						    'entry_firstname' => $billing_firstname,
						    'entry_lastname' => $billing_lastname,
						    'entry_street_address' => $billing_street_address,
						    'entry_address2' => ((strlen($billing_address2) > 0) ? $billing_address2 : 'null'),
						    'entry_postcode' => $billing_postcode,
						    'entry_city' => $billing_city,
						    'entry_country_id' => $billing_country);
    if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $billing_gender;
    if ((ACCOUNT_COMPANY == 'true') && (strlen($billing_company) > 0)) $sql_data_array['entry_company'] = $billing_company;
    if ((ACCOUNT_SUBURB == 'true') && (strlen($billing_suburb) > 0)) $sql_data_array['entry_suburb'] = $billing_suburb;
    if (ACCOUNT_STATE == 'true') {
	  if ($zone_id > 0) {
	    $sql_data_array['entry_zone_id'] = $billing_zone_id;
	    $sql_data_array['entry_state'] = 'null';
	  } else {
	    $sql_data_array['entry_zone_id'] = '0';
	    $sql_data_array['entry_state'] = $billing_state;
	  }
    }
    tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
    $billing_address_id = tep_db_insert_id();
    tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_billing_address_id = '" . (int)$billing_address_id . "' where customers_id = '" . (int)$customer_id . "'");
  }
  if ($shipping_is_other == 'M') { // shipping is same as mailing
    tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_shipping_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");
    $shipping_address_id = $address_id;
  } elseif ($shipping_is_other == 'B') { // shipping is same as billing
    tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_shipping_address_id = '" . (int)$billing_address_id . "' where customers_id = '" . (int)$customer_id . "'");
    $shipping_address_id = $billing_address_id;
  } else { // if shipping different than mailing and billing add shipping address to database
    $sql_data_array = array('customers_id' => $customer_id,
						    'entry_firstname' => $shipping_firstname,
						    'entry_lastname' => $shipping_lastname,
						    'entry_street_address' => $shipping_street_address,
						    'entry_address2' => ((strlen($shipping_address2) > 0) ? $shipping_address2 : 'null'),
						    'entry_postcode' => $shipping_postcode,
						    'entry_city' => $shipping_city,
						    'entry_country_id' => $shipping_country);
    if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $shipping_gender;
    if ((ACCOUNT_COMPANY == 'true') && (strlen($shipping_company) > 0)) $sql_data_array['entry_company'] = $shipping_company;
    if ((ACCOUNT_SUBURB == 'true') && (strlen($shipping_suburb) > 0)) $sql_data_array['entry_suburb'] = $shipping_suburb;
    if (ACCOUNT_STATE == 'true') {
	  if ($zone_id > 0) {
	    $sql_data_array['entry_zone_id'] = $shipping_zone_id;
	    $sql_data_array['entry_state'] = 'null';
	  } else {
	    $sql_data_array['entry_zone_id'] = '0';
	    $sql_data_array['entry_state'] = $shipping_state;
	  }
    }
    tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
    $shipping_address_id = tep_db_insert_id();
    tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_shipping_address_id = '" . (int)$shipping_address_id . "' where customers_id = '" . (int)$customer_id . "'");
  }
  if (SESSION_RECREATE == 'True') {
    tep_session_recreate();
  }
// BOF Separate Pricing Per Customer
// register SPPC session variables for the new customer
// if there is code above that puts new customers directly into another customer group (default is retail)
// then the below code need not be changed, it uses the newly inserted customer group
  $check_customer_group_info = tep_db_query("select c.customers_group_id, cg.customers_group_show_tax, cg.customers_group_tax_exempt, cg.group_specific_taxes_exempt from " . TABLE_CUSTOMERS . " c left join " . TABLE_CUSTOMERS_GROUPS . " cg using(customers_group_id) where c.customers_id = '" . $customer_id . "'");
  $customer_group_info = tep_db_fetch_array($check_customer_group_info);
  $sppc_customer_group_id = $customer_group_info['customers_group_id'];
  $sppc_customer_group_show_tax = (int)$customer_group_info['customers_group_show_tax'];
  $sppc_customer_group_tax_exempt = (int)$customer_group_info['customers_group_tax_exempt'];
  $sppc_customer_specific_taxes_exempt = '';
  if (tep_not_null($customer_group_info['group_specific_taxes_exempt'])) {
    $sppc_customer_specific_taxes_exempt = $customer_group_info['group_specific_taxes_exempt'];
  }
// EOF Separate Pricing Per Customer
  $customer_first_name = $firstname;
  $customer_default_address_id = $address_id;
  $customer_default_billing_address_id = $billing_address_id;
  $customer_default_shipping_address_id = $shipping_address_id;
  $customer_country_id = $country;
  $customer_zone_id = $zone_id;
  $customer_name = $firstname . ' ' . $lastname;
  tep_session_register('customer_id');
  tep_session_register('customer_first_name');
  tep_session_register('customer_name');
  tep_session_register('customer_default_address_id');
  tep_session_register('customer_default_billing_address_id');
  tep_session_register('customer_default_shipping_address_id');
  tep_session_register('customer_country_id');
  tep_session_register('customer_zone_id');

// BOF Separate Pricing Per Customer
  tep_session_register('sppc_customer_group_id');
  tep_session_register('sppc_customer_group_show_tax');
  tep_session_register('sppc_customer_group_tax_exempt');
  tep_session_register('sppc_customer_specific_taxes_exempt');
// EOF Separate Pricing Per Customer  
// reset session token
  $sessiontoken = md5(tep_rand() . tep_rand() . tep_rand() . tep_rand());
// restore cart contents
  $cart->restore_contents();
// restore wishlist to sesssion
//	 $wishList->restore_wishlist();
// build the message content
  $name = $firstname . ' ' . $lastname;
  if (ACCOUNT_GENDER == 'true') {
	 if ($gender == 'm') {
	   $email_text = sprintf(EMAIL_GREET_MR, $lastname);
	 } else {
	   $email_text = sprintf(EMAIL_GREET_MS, $lastname);
	 }
  } else {
    $email_text = sprintf(EMAIL_GREET_NONE, $firstname);
  }
  $email_text .= EMAIL_WELCOME . EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
  tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);

// BOF Separate Pricing Per Customer: alert shop owner of account created by a company
// if you would like to have an email when either a company name has been entered in
// the appropriate field or a tax id number, or both then uncomment the next line and comment the default
// setting: only email when a tax_id number has been given
//    if ( (ACCOUNT_COMPANY == 'true' && tep_not_null($company) ) || (ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) ) {
  if ( ACCOUNT_COMPANY == 'true' && tep_not_null($company_tax_id) ) {
  $alert_email_text = "Please note that " . $firstname . " " . $lastname . " of the company: " . $company . " has created an account.";
  tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, 'Company account created', $alert_email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
  }
// EOF Separate Pricing Per Customer: alert shop owner of account created by a company  
  tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));

}
 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
 require(DIR_WS_INCLUDES . 'template_top.php');
 //require('includes/form_check.js.php');
?>
<!-- hide and disable all state lists before showing list pertaining to currently chosen country //-->
<script type="text/javascript">
 function ShowNewList(add_id) {
   var id = new Array(<?php echo implode(', ', $cl); ?>);
   var x, item;
   for (x = 0; x <id.length; x++) {
<?php
   if (ACCOUNT_STATE == 'true') {
?>
  item = document.getElementById(add_id + id[x]);
  if (item) { item.disabled = true; }
  item = document.getElementById(add_id + 'sp' + id[x]);
  if (item) { item.style.display = 'none'; }
<?php
   }
?>
  item = document.getElementById(add_id + 'pc' + id[x]);
  if (item) { item.style.display = 'none'; }
   }  
   var pm = document.getElementById(add_id + 'ctry');
   id = pm.value;
<?php
   if (ACCOUNT_STATE == 'true') {
?>
   item = document.getElementById(add_id + id);
   item.disabled = false;
   item = document.getElementById(add_id + 'sp' + id);
   item.style.display = '';
<?php
   }
?>
   item = document.getElementById(add_id + 'pc' + id);
   item.style.display = '';
}
function CopyMailingToBilling() {
   document.create_account.billing_country.value = document.create_account.country.value;
  if (document.create_account.billing_is_mailing.checked) {
 <?php if (ACCOUNT_GENDER == 'true') { ?>
 document.create_account.billing_gender.value = document.create_account.gender.value;
 <?php } ?>
 document.create_account.billing_firstname.value = document.create_account.firstname.value;
 document.create_account.billing_lastname.value = document.create_account.lastname.value;
 <?php if (ACCOUNT_COMPANY == 'true') { ?>
 document.create_account.billing_company.value = document.create_account.company.value;
 <?php } ?>
 document.create_account.billing_street_address.value = document.create_account.street_address.value;
 document.create_account.billing_address2.value = document.create_account.address2.value;
 <?php if (ACCOUNT_SUBURB == 'true') { ?>
 document.create_account.billing_suburb.value = document.create_account.suburb.value;
 <?php } ?>
 document.create_account.billing_postcode.value = document.create_account.postcode.value;
 document.create_account.billing_city.value = document.create_account.city.value;
 <?php if (ACCOUNT_STATE == 'true') { ?>
 ShowNewList('B');
 var mailing = document.getElementById('M' + document.create_account.country.value);
 var billing = document.getElementById('B' + document.create_account.country.value);
 billing.value = mailing.value;
 <?php } ?>
  } else {
 <?php if (ACCOUNT_GENDER == 'true') { ?>
 document.create_account.billing_gender.value = '';
 <?php } ?>
 document.create_account.billing_firstname.value = '';
 document.create_account.billing_lastname.value = '';
 <?php if (ACCOUNT_COMPANY == 'true') { ?>
 document.create_account.billing_company.value = '';
 <?php } ?>
 document.create_account.billing_street_address.value = '';
 document.create_account.billing_address2.value = '';
 <?php if (ACCOUNT_SUBURB == 'true') { ?>
 document.create_account.billing_suburb.value = '';
 <?php } ?>
 document.create_account.billing_postcode.value = '';
 document.create_account.billing_city.value = '';
 <?php if (ACCOUNT_STATE == 'true') { ?>
 ShowNewList('B');
 var billing = document.getElementById('B' + document.create_account.country.value);
 billing.value = '';
 <?php } ?>
  }
}
function CopyMailingToShipping() {
 <?php if (ACCOUNT_GENDER == 'true') { ?>
 document.create_account.shipping_gender.value = document.create_account.gender.value;
 <?php } ?>
 document.create_account.shipping_firstname.value = document.create_account.firstname.value;
 document.create_account.shipping_lastname.value = document.create_account.lastname.value;
 <?php if (ACCOUNT_COMPANY == 'true') { ?>
 document.create_account.shipping_company.value = document.create_account.company.value;
 <?php } ?>
 document.create_account.shipping_country.value = document.create_account.country.value;
 document.create_account.shipping_street_address.value = document.create_account.street_address.value;
 document.create_account.shipping_address2.value = document.create_account.address2.value;
 <?php if (ACCOUNT_SUBURB == 'true') { ?>
 document.create_account.shipping_suburb.value = document.create_account.suburb.value;
 <?php } ?>
 document.create_account.shipping_postcode.value = document.create_account.postcode.value;
 document.create_account.shipping_city.value = document.create_account.city.value;
 <?php if (ACCOUNT_STATE == 'true') { ?>
 ShowNewList('S');
 var mailing = document.getElementById('M' + document.create_account.country.value);
 var shipping = document.getElementById('S' + document.create_account.country.value);
 shipping.value = mailing.value;
 <?php } ?>
}
function CopyBillingToShipping() {
 <?php if (ACCOUNT_GENDER == 'true') { ?>
 document.create_account.shipping_gender.value = document.create_account.billing_gender.value;
 <?php } ?>
 document.create_account.shipping_firstname.value = document.create_account.billing_firstname.value;
 document.create_account.shipping_lastname.value = document.create_account.billing_lastname.value;
 <?php if (ACCOUNT_COMPANY == 'true') { ?>
 document.create_account.shipping_company.value = document.create_account.billing_company.value;
 <?php } ?>
 document.create_account.shipping_country.value = document.create_account.billing_country.value;
 document.create_account.shipping_street_address.value = document.create_account.billing_street_address.value;
 document.create_account.shipping_address2.value = document.create_account.billing_address2.value;
 <?php if (ACCOUNT_SUBURB == 'true') { ?>
 document.create_account.shipping_suburb.value = document.create_account.billing_suburb.value;
 <?php } ?>
 document.create_account.shipping_postcode.value = document.create_account.billing_postcode.value;
 document.create_account.shipping_city.value = document.create_account.billing_city.value;
 <?php if (ACCOUNT_STATE == 'true') { ?>
 ShowNewList('S');
 var billing = document.getElementById('B' + document.create_account.billing_country.value);
 var shipping = document.getElementById('S' + document.create_account.billing_country.value);
 shipping.value = billing.value;
 <?php } ?>
}
function ClearShippingAddress() {
 <?php if (ACCOUNT_GENDER == 'true') { ?>
 document.create_account.shipping_gender.value = '';
 <?php } ?>
 document.create_account.shipping_firstname.value = '';
 document.create_account.shipping_lastname.value = '';
 <?php if (ACCOUNT_COMPANY == 'true') { ?>
 document.create_account.shipping_company.value = '';
 <?php } ?>
 document.create_account.shipping_country.value = document.create_account.country.value;
 document.create_account.shipping_street_address.value = '';
 document.create_account.shipping_address2.value = '';
 <?php if (ACCOUNT_SUBURB == 'true') { ?>
 document.create_account.shipping_suburb.value = '';
 <?php } ?>
 document.create_account.shipping_postcode.value = '';
 document.create_account.shipping_city.value = '';
 <?php if (ACCOUNT_STATE == 'true') { ?>
 ShowNewList('S');
 var shipping = document.getElementById('S' + document.create_account.shipping_country.value);
 shipping.value = '';
 <?php } ?>
}
</script>
<h1><?php echo HEADING_TITLE; ?></h1>
<?php
 if ($messageStack->size('create_account') > 0) {
   echo $messageStack->output('create_account');
 }
?>
<p><?php echo sprintf(TEXT_ORIGIN_LOGIN, tep_href_link(FILENAME_LOGIN, tep_get_all_get_params(), 'SSL')); ?></p>
<?php echo tep_draw_form('create_account', tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'), 'post', 'onsubmit="return check_form(create_account);"', true) . tep_draw_hidden_field('action', 'process'); ?>
<!-- THIS IS ADDED FOR SPPC -->
<?php
 if (ACCOUNT_COMPANY == 'true') {
?>
<span class="inputRequirement" style="float: right;"><?php echo FORM_REQUIRED_INFORMATION; ?></span>
 <h2><?php echo CATEGORY_COMPANY; ?></h2>
 <div class="contentText">
   <table border="0" cellspacing="2" cellpadding="2" width="100%">

  <tr>
    <td class="fieldKey"><?php echo ENTRY_COMPANY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('company') . ' ' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': '<span class="inputRequirement">' . ENTRY_REQUIRED . '</span>'); ?></td>
  </tr>
<!-- BOF Separate Pricing Per Customer: field for tax id number -->
  <tr>
    <td class="fieldKey"><?php echo ENTRY_COMPANY_TAX_ID; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('company_tax_id') . ' ' . (tep_not_null(ENTRY_COMPANY_TAX_ID_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TAX_ID_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<!-- EOF Separate Pricing Per Customer: field for tax id number -->
   </table>
 </div>
 <!-- EOF ADDED FOR SPPC -->
<div class="contentContainer">
 <div>
   <h2><?php echo CATEGORY_PERSONAL; ?></h2>
 </div>
 <div class="contentText">
   <table border="0" cellspacing="2" cellpadding="2" width="100%">
<?php
 if (ACCOUNT_GENDER == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_GENDER; ?></td>
    <td class="fieldValue"><?php echo tep_draw_radio_field('gender', 'm') . '  ' . MALE . '  ' . tep_draw_radio_field('gender', 'f') . '  ' . FEMALE . ' ' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_FIRST_NAME; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('firstname', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_LAST_NAME; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('lastname', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_DOB == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_DATE_OF_BIRTH; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('dob', '', 'id="dob"') . ' ' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?><script type="text/javascript">$('#dob').datepicker({dateFormat: '<?php echo JQUERY_DATEPICKER_FORMAT; ?>', changeMonth: true, changeYear: true, yearRange: '-100:+0'});</script></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_EMAIL_ADDRESS; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('email_address', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_CONFIRM_EMAIL; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('confirm_email_address', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<!--  </table>
   <h2><?php echo CATEGORY_CONTACT; ?></h2>
 <div class="contentText">
   <table border="0" cellspacing="2" cellpadding="2" width="100%"> -->
  <tr>
    <td class="fieldKey"><?php echo ENTRY_TELEPHONE_NUMBER; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('telephone', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_ALTERNATE_TELEPHONE; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('alternate_telephone', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_ALTERNATE_TELEPHONE_TEXT) ? '<span class="inputRequirement">' . ENTRY_ALTERNATE_TELEPHONE_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_FAX_NUMBER; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('fax', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_NEWSLETTER; ?></td>
    <td class="fieldValue"><?php echo tep_draw_checkbox_field('newsletter', '1', true) . ' ' . (tep_not_null(ENTRY_NEWSLETTER_TEXT) ? '<span class="inputRequirement">' . ENTRY_NEWSLETTER_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
   </table>
 </div>

<?php
 }
?> 
 <h2><?php echo TEXT_ADDRESS_MAILING; ?></h2>
 <?php if (ACCOUNT_COMPANY == 'true') echo ENTRY_COMPANY_NOTE; ?>
 <div class="contentText">
   <table border="0" cellspacing="2" cellpadding="2" width="100%">
<?php
 if (ACCOUNT_COMPANY == 'true') {
?>
<!--	  <tr>
    <td class="fieldKey"><?php //echo ENTRY_COMPANY; ?></td>
    <td class="fieldValue"><?php// echo tep_draw_input_field('company', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr> -->
<?php
 }
 if (ACCOUNT_STATE == 'true') {
   $parms = 'id="Mctry" onchange="ShowNewList(\'M\')"';
 } else {
   $parms = '';
 }
 if (isset($HTTP_POST_VARS['country'])) {
   $select = $HTTP_POST_VARS['country'];
 } else {
   $select = STORE_COUNTRY;
 }
?>

  <tr>
    <td class="fieldKey"><?php echo ENTRY_STREET_ADDRESS; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('street_address', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_ADDRESS2; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('address2', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_ADDRESS2_TEXT) ? '<span class="inputRequirement">' . ENTRY_ADDRESS2_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_SUBURB == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_SUBURB; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('suburb', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_COUNTRY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_pull_down_menu('country', $countries_array, $select, $parms) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_POST_CODE; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('postcode', '', 'size="50"') . ' ';
  foreach ($cl as $id) {
 if (tep_not_null($country_info[$id]['countries_postal_validation'])) {
   echo '<span class="inputRequirement" id="Mpc' . $country_info[$id]['countries_id'] . '"' . ($id == $select ? '' : ' style="display:none"') . '>' . ENTRY_POST_CODE_TEXT . "</span>";
 } else {
   echo '<span class="inputOptional" id="Mpc' . $country_info[$id]['countries_id'] . '"' . ($id == $select ? '' : ' style="display:none"') . '>' . ENTRY_OPTIONAL . "</span>";
 }
  }
?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_CITY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('city', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_STATE == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_STATE; ?></td>
    <td class="fieldValue">
<?php
   foreach ($cl as $id) {
  if ($id != $select) { //if current list is not for selected country set list to not displayed and disabled
    $parms = 'disabled="disabled" ';
    $span = '<span style="display:none" id="Msp' . $id .'">';
  } else {
    $parms = '';
    $span = '<span id="Msp' . $id .'">';
  }
  $parms .= 'id="M' . $id . '"'; // set id for list for javascript show/hide process
  echo $span;
  if ($allzones[$id] === false) { // if no zones for country draw text field
    echo tep_draw_input_field('state', '', $parms . ' size="50"');
  } else {
    echo tep_draw_pull_down_menu('zone_id', $allzones[$id], '', $parms);
  }
  if ($country_info[$id]['requires_state'] == 1) {
    echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;
  } else {
    echo ' <span class="inputOptional">' . ENTRY_OPTIONAL;
  }
  echo "</span></span>\n";
   }
?>
    </td>
  </tr>
<?php
 }
?>
   </table>
 </div>
 <h2><?php echo TEXT_ADDRESS_BILLING; ?></h2>
 <?php
  if (ACCOUNT_COMPANY == 'true') echo ENTRY_COMPANY_NOTE . "<br />\n";
  echo tep_draw_checkbox_field('billing_is_mailing', 'Y', '', 'onclick="CopyMailingToBilling()"') . ' ' . TEXT_SAME_AS_MAILING;
 ?>
 <div class="contentText">
   <table border="0" cellspacing="2" cellpadding="2" width="100%">
<?php
 if (ACCOUNT_GENDER == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_GENDER; ?></td>
    <td class="fieldValue"><?php echo tep_draw_radio_field('billing_gender', 'm') . '  ' . MALE . '  ' . tep_draw_radio_field('billing_gender', 'f') . '  ' . FEMALE . ' ' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_FIRST_NAME; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_firstname', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_LAST_NAME; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_lastname', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_COMPANY == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_COMPANY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_company', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
 if (ACCOUNT_STATE == 'true') {
   $parms = 'id="Bctry" onchange="ShowNewList(\'B\')"';
 } else {
   $parms = '';
 }
 if (isset($HTTP_POST_VARS['billing_country'])) {
   $select = $HTTP_POST_VARS['billing_country'];
 } else {
   $select = STORE_COUNTRY;
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_COUNTRY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_pull_down_menu('billing_country', $countries_array, $select, $parms) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_STREET_ADDRESS; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_street_address', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_ADDRESS2; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_address2', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_ADDRESS2_TEXT) ? '<span class="inputRequirement">' . ENTRY_ADDRESS2_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_SUBURB == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_SUBURB; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_suburb', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_POST_CODE; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_postcode', '', 'size="50"') . ' ';
  foreach ($cl as $id) {
 if (tep_not_null($country_info[$id]['countries_postal_validation'])) {
   echo '<span class="inputRequirement" id="Bpc' . $country_info[$id]['countries_id'] . '"' . ($id == $select ? '' : ' style="display:none"') . '>' . ENTRY_POST_CODE_TEXT . "</span>";
 } else {
   echo '<span class="inputOptional" id="Bpc' . $country_info[$id]['countries_id'] . '"' . ($id == $select ? '' : ' style="display:none"') . '>' . ENTRY_OPTIONAL . "</span>";
 }
  }
	 ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_CITY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('billing_city', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_STATE == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_STATE; ?></td>
    <td class="fieldValue">
<?php
   foreach ($cl as $id) {
  if ($id != $select) { //if current list is not for selected country set list to not displayed and disabled
    $parms = 'disabled="disabled" ';
    $span = '<span style="display:none" id="Bsp' . $id .'">';
  } else {
    $parms = '';
    $span = '<span id="Bsp' . $id .'">';
  }
  $parms .= 'id="B' . $id . '"'; // set id for list for javascript show/hide process
  echo $span;
  if ($allzones[$id] === false) { // if no zones for country draw text field
    echo tep_draw_input_field('billing_state', '', $parms . ' size="50"');
  } else {
    echo tep_draw_pull_down_menu('billing_zone_id', $allzones[$id], '', $parms);
  }
  if ($country_info[$id]['requires_state'] == 1) {
    echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;
  } else {
    echo ' <span class="inputOptional">' . ENTRY_OPTIONAL;
  }
  echo "</span></span>\n";
   }
?>
    </td>
  </tr>
<?php
 }
?>
   </table>
 </div>
 <h2><?php echo TEXT_ADDRESS_SHIPPING; ?></h2>
 <?php
  if (ACCOUNT_COMPANY == 'true') echo ENTRY_COMPANY_NOTE . "<br />\n";
  echo TEXT_POBOX_WARN . "<br />\n";
  echo tep_draw_radio_field('shipping_is_other', 'M', false, 'onclick="CopyMailingToShipping()"') . ' ' . TEXT_SAME_AS_MAILING . "<br />\n";
  echo tep_draw_radio_field('shipping_is_other', 'B', false, 'onclick="CopyBillingToShipping()"') . ' ' . TEXT_SAME_AS_BILLING . "<br />\n";
  echo tep_draw_radio_field('shipping_is_other', 'S', false, 'onclick="ClearShippingAddress()"') . ' ' . TEXT_SHIPPING_IS_DIFF;
 ?>
 <div class="contentText">
   <table border="0" cellspacing="2" cellpadding="2" width="100%">
<?php
 if (ACCOUNT_GENDER == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_GENDER; ?></td>
    <td class="fieldValue"><?php echo tep_draw_radio_field('shipping_gender', 'm') . '  ' . MALE . '  ' . tep_draw_radio_field('shipping_gender', 'f') . '  ' . FEMALE . ' ' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_FIRST_NAME; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_firstname', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_LAST_NAME; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_lastname', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_COMPANY == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_COMPANY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_company', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
 if (ACCOUNT_STATE == 'true') {
   $parms = 'id="Sctry" onchange="ShowNewList(\'S\')"';
 } else {
   $parms = '';
 }
 if (isset($HTTP_POST_VARS['shipping_country'])) {
   $select = $HTTP_POST_VARS['shipping_country'];
 } else {
   $select = STORE_COUNTRY;
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_COUNTRY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_pull_down_menu('shipping_country', $countries_array, $select, $parms) . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_STREET_ADDRESS; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_street_address', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_ADDRESS2; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_address2', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_ADDRESS2_TEXT) ? '<span class="inputRequirement">' . ENTRY_ADDRESS2_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_SUBURB == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_SUBURB; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_suburb', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_POST_CODE; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_postcode', '', 'size="50"') . ' ';
  foreach ($cl as $id) {
 if (tep_not_null($country_info[$id]['countries_postal_validation'])) {
   echo '<span class="inputRequirement" id="Spc' . $country_info[$id]['countries_id'] . '"' . ($id == $select ? '' : ' style="display:none"') . '>' . ENTRY_POST_CODE_TEXT . "</span>";
 } else {
   echo '<span class="inputOptional" id="Spc' . $country_info[$id]['countries_id'] . '"' . ($id == $select ? '' : ' style="display:none"') . '>' . ENTRY_OPTIONAL . "</span>";
 }
  }
    ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_CITY; ?></td>
    <td class="fieldValue"><?php echo tep_draw_input_field('shipping_city', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
<?php
 if (ACCOUNT_STATE == 'true') {
?>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_STATE; ?></td>
    <td class="fieldValue">
<?php
   foreach ($cl as $id) {
  if ($id != $select) { //if current list is not for selected country set list to not displayed and disabled
    $span = '<span style="display:none" id="Ssp' . $id .'">';
    $parms = 'disabled="disabled" ';
  } else {
    $span = '<span id="Ssp' . $id .'">';
    $parms = '';
  }
  $parms .= 'id="S' . $id . '"'; // set id for list for javascript show/hide process
  echo $span;
  if ($allzones[$id] === false) { // if no zones for country draw text field
    echo tep_draw_input_field('shipping_state', '', $parms . ' size="50"');
  } else {
    echo tep_draw_pull_down_menu('shipping_zone_id', $allzones[$id], '', $parms);
  }
  if ($country_info[$id]['requires_state'] == 1) {
    echo ' <span class="inputRequirement">' . ENTRY_STATE_TEXT;
  } else {
    echo ' <span class="inputOptional">' . ENTRY_OPTIONAL;
  }
  echo "</span></span>\n";
   }
?>
    </td>
  </tr>
<?php
 }
?>
   </table>
 </div>

 <h2><?php echo CATEGORY_PASSWORD; ?></h2>
 <div class="contentText">
   <?php echo TEXT_PASSWORD_NOTE; ?>
   <table border="0" cellspacing="2" cellpadding="2" width="100%">
  <tr>
    <td class="fieldKey"><?php echo ENTRY_PASSWORD; ?></td>
    <td class="fieldValue"><?php echo tep_draw_password_field('password', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_PASSWORD_TEXT) ? '<span class="inputRequirement">' . ENTRY_PASSWORD_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
  <tr>
    <td class="fieldKey"><?php echo ENTRY_PASSWORD_CONFIRMATION; ?></td>
    <td class="fieldValue"><?php echo tep_draw_password_field('confirmation', '', 'size="50"') . ' ' . (tep_not_null(ENTRY_PASSWORD_CONFIRMATION_TEXT) ? '<span class="inputRequirement">' . ENTRY_PASSWORD_CONFIRMATION_TEXT . '</span>': '<span class="inputOptional">' . ENTRY_OPTIONAL . '</span>'); ?></td>
  </tr>
   </table>
 </div>
 <div class="buttonSet">
   <span class="buttonAction"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'person', null, 'primary'); ?></span>
 </div>
</div>
</form>

<?php
 require(DIR_WS_INCLUDES . 'template_bottom.php');
 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Posted

See if it helps to replace

 

<?php
if ($messageStack->size('create_account') > 0) {
 echo $messageStack->output('create_account');
}
?>

 

with

 

<?php
if (isset($HTTP_POST_VARS['action']) &&
$HTTP_POST_VARS['action'] == 'process' &&
$messageStack->size('create_account') > 0) {
 echo $messageStack->output('create_account');
}
?>

 

to suppress the 'empty field' errors, the first time that create_account is displayed. Not really tested, because it needs to be in sequence in order to establish a session.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...