public function register() { if (!isset($this->session->userdata['user_id'])) { $data = array(); $model = new Common_model(); if ($this->input->post()) { $redirect_url = base_url(); if ($this->input->get('next')) { $redirect_url = $this->input->get('next'); } $arr = $this->input->post(); // prd($arr); $user_email = trim(strtolower($arr["user_email"])); $is_email_exists = $model->is_exists('user_id', TABLE_USERS, array('user_email' => $user_email)); if (empty($is_email_exists)) { // valid email $verification_code = substr(getEncryptedString($arr['user_email'] . $arr['user_gender'] . time()), 0, 30); $user_username = getUniqueUsernameFromEmail($user_email); $location_details = get_location_details_from_google(trim($arr['user_location'])); $location_lat_long = getLatLonByAddress(trim($arr['user_location'])); $data_array = array('user_fullname' => $arr['user_fullname'], 'user_gender' => strtolower($arr['user_gender']), 'user_username' => $user_username, 'user_email' => $user_email, 'user_password' => md5($arr['user_password']), 'user_ipaddress' => USER_IP, 'user_useragent' => USER_AGENT, 'user_created_on' => date('Y-m-d H:i:s'), 'user_status' => '0', 'user_verification_code' => $verification_code, 'user_city' => $location_details['city'], 'user_state' => $location_details['state'], 'user_country' => $location_details['country'], 'user_location' => trim($arr['user_location']), 'user_latitude' => $location_lat_long['latitude'], 'user_longitude' => $location_lat_long['longitude']); $user_id = $model->insertData(TABLE_USERS, $data_array); // updating redis keys now $this->redis_functions->set_user_profile_data($user_username); if (USER_IP != '127.0.0.1') { $verification_url = base_url('activate?code=' . $verification_code); $this->load->library('EmailTemplates'); $EmailTemplates = new EmailTemplates(); $messageText = $EmailTemplates->registerEmail(ucwords($arr['user_fullname']), $verification_url); $email_model = new Email_model(); $email_model->sendMail($arr['user_email'], 'Verification Email - ' . $this->redis_functions->get_site_setting('SITE_NAME'), $messageText); } $this->session->set_flashdata('success', '<strong>Success!</strong> We have sent you an email. Please verify your email address'); redirect($redirect_url); } else { // invalid email $this->session->set_flashdata('error', '<strong>Oops!</strong> Email already exists'); $this->session->set_flashdata('post', $arr); redirect(base_url('register?next=' . $this->input->get('next'))); } } else { $page_title = 'Register'; $input_arr = array(base_url() => 'Home', '#' => $page_title); $breadcrumbs = get_breadcrumbs($input_arr); $data["breadcrumbs"] = $breadcrumbs; $data["page_title"] = $page_title; $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME'); $this->template->write_view("content", "pages/index/register", $data); $this->template->render(); } } else { redirect('my-account'); } }