//----------------------------- CleverReach Starts --------------------------------------
 if (CR_ENABLED == 'true') {
     $client = new SoapClient('http://api.cleverreach.com/soap/interface_v5.1.php?wsdl');
     // Check if email was changed and if so, delete old CleverReach record and create a new one.
     $query = 'SELECT customers_email_address FROM ' . TABLE_CUSTOMERS . ' WHERE customers_id = ' . (int) $customer_id;
     $res = mysql_query($query);
     if ($res && mysql_num_rows($res)) {
         $old_email_address = mysql_result($res, 0, 0);
     }
     if ($old_email_address != $email_address) {
         $client->receiverDelete(CR_API_KEY, CR_LIST_ID, $old_email_address);
         $crReceiver = array('email' => utf8_encode($email_address), 'source' => utf8_encode('SwissCart'), 'attributes' => array(0 => array('key' => 'firstname', 'value' => utf8_encode($firstname)), 1 => array('key' => 'lastname', 'value' => utf8_encode($lastname))));
         $client->receiverAdd(CR_API_KEY, CR_LIST_ID, $crReceiver);
     } else {
         $crReceiver = array('email' => utf8_encode($email_address), 'source' => utf8_encode('SwissCart'), 'attributes' => array(0 => array('key' => 'firstname', 'value' => utf8_encode($firstname)), 1 => array('key' => 'lastname', 'value' => utf8_encode($lastname))));
         $ret = $client->receiverUpdate(CR_API_KEY, CR_LIST_ID, $crReceiver);
     }
 }
 //------------------------------ CleverReach Ends --------------------------------------
 $sql_data_array = array('customers_firstname' => $firstname, 'customers_lastname' => $lastname, 'customers_email_address' => $email_address, 'customers_telephone' => $telephone, 'customers_fax' => $fax);
 if (ACCOUNT_GENDER == 'true') {
     $sql_data_array['customers_gender'] = $gender;
 }
 if (ACCOUNT_DOB == 'true') {
     $sql_data_array['customers_dob'] = tep_date_raw($dob);
 }
 tep_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', "customers_id = '" . (int) $customer_id . "'");
 tep_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int) $customer_id . "'");
 $sql_data_array = array('entry_firstname' => $firstname, 'entry_lastname' => $lastname);
 tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int) $customer_id . "' and address_book_id = '" . (int) $customer_default_address_id . "'");
 // reset the session variables