function create($customers_id = 0) { //if customer is 0, then is a new account...(needs to be added in for editing) //add data for table customers which hold most of the primary customers info $sql_data_array = array('customers_firstname' => $this->firstname, 'customers_lastname' => $this->lastname, 'customers_email_address' => $this->email_address, 'customers_telephone' => $this->telephone, 'customers_fax' => $this->fax, 'customers_newsletter' => $this->newsletter, 'customers_gender' => $this->gender, 'customers_dob' => $this->dob); if ($customers_id == 0) { $sql_data_array['customers_password'] = $this->password; smn_db_perform(TABLE_CUSTOMERS, $sql_data_array); $this->customer_id = smn_db_insert_id(); //primary KEY for customer } else { smn_db_perform(TABLE_CUSTOMERS, $sql_data_array, 'update', 'customers_id=' . (int) $customers_id); $this->customer_id = (int) $customers_id; } //start building array for adress book entries using the default address given on sign up $sql_data_array = array('customers_id' => $this->customer_id, 'entry_firstname' => $this->firstname, 'entry_lastname' => $this->lastname, 'entry_company' => $this->company, 'entry_street_address' => $this->street_address, 'entry_postcode' => $this->postcode, 'entry_city' => $this->city, 'entry_country_id' => $this->country_id, 'entry_gender' => $this->gender, 'entry_zone_id' => $this->zone_id, 'entry_state' => $this->state); if ($customers_id == 0) { smn_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array); $this->address_id = smn_db_insert_id(); smn_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int) $this->address_id . "' where customers_id = '" . (int) $this->customer_id . "'"); smn_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int) $this->customer_id . "', '0', now())"); } else { smn_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', 'customers_id=' . (int) $customers_id); smn_db_query("update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_account_last_modified = now() where customers_info_id = '" . (int) $customer_id . "'"); } if (SESSION_RECREATE == 'True') { smn_session_recreate(); } return $this->customer_id; }
$_GET['login'] = '******'; } else { $check_customer = smn_db_fetch_array($check_customer_query); // Check that password is good if (!smn_validate_password($affiliate_password, $check_customer['customers_password'])) { $_GET['login'] = '******'; } else { /*Changed the code to set the session of user and sales agent if the login is success by Cimi*/ /*$affiliate_id = $check_affiliate['affiliate_id']; smn_session_register('affiliate_id'); $date_now = date('Ymd'); smn_db_query("update " . TABLE_AFFILIATE . " set affiliate_date_of_last_logon = now(), affiliate_number_of_logons = affiliate_number_of_logons + 1 where affiliate_id = '" . $affiliate_id . "'");*/ if (SESSION_RECREATE == 'True') { smn_session_recreate(); } $check_country_query = smn_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $check_customer['customers_id'] . "' and address_book_id = '" . (int) $check_customer['customers_default_address_id'] . "'"); $check_country = smn_db_fetch_array($check_country_query); $affiliate_id = $check_affiliate['affiliate_id']; smn_session_register('affiliate_id'); $customer_id = $check_customer['customers_id']; $customer_default_address_id = $check_customer['customers_default_address_id']; $customer_first_name = $check_customer['customers_firstname']; $customer_country_id = $check_country['entry_country_id']; $customer_zone_id = $check_country['entry_zone_id']; smn_session_register('customer_id'); smn_session_register('customer_default_address_id'); smn_session_register('customer_first_name'); smn_session_register('customer_country_id'); smn_session_register('customer_zone_id');