public function contact() { $this->data['title'] = 'Liên hệ với - eShop'; if ($this->input->post(NULL, TRUE)) { $contact = $this->input->post(NULL, TRUE); $error = FALSE; if (!Public_class::isValidEmail($contact['email'])) { $error .= '<li>- Sai định dạng email</li>'; } if (strlen($contact['name']) < 3) { $error .= '<li>- Sai định dạng họ & tên</li>'; } if (!Public_class::isValidPhoneNumber($contact['telephone'])) { $error .= '<li>- Sai định dạng điện thoại</li>'; } if (!$contact['comment']) { $error .= '<li>- Chưa nhập nội dung</li>'; } if (!$error) { $this->load->model('Mcontact'); $dt = array('username' => $contact['name'], 'email' => $contact['email'], 'mobile' => $contact['telephone'], 'content' => $contact['comment'], 'type' => 0, 'status' => 0, 'created_at' => time()); $result = $this->Mcontact->insertItem($dt); if ($result) { $this->data['alert_success'] = TRUE; } else { $error .= '<li>- Không thể gửi thông tin. Vui lòng thử lại sau</li>'; } } $this->data['alert_error'] = $error; } $this->data['view_map'] = TRUE; $this->data['template'] = 'frontend/contact'; $this->load->view('frontend/layout', $this->data); }
public function check_username() { if ($this->input->is_ajax_request()) { $ajax = new AjaxResponse(); $nameUser = strtolower($this->input->post('username')); if ($this->_inValidUsername($nameUser) != true) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-username'; $ajax->message = 'Tên đăng nhập này không được sử dụng!'; exit($ajax->toString()); } if (Public_class::isValidUsername($nameUser) != 1) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-username'; $ajax->message = 'Tên đăng nhập từ 3-15 ký tự và không chứa ký tự đặc biệt!'; exit($ajax->toString()); } $user = $this->db->get_where('users', array('username' => trim($nameUser))); if ($user->num_rows() > 0) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-username'; $ajax->message = 'Tên đăng nhập này đã tồn tại!'; exit($ajax->toString()); } $ajax->type = AjaxResponse::SUCCESS; $ajax->message = 'Tên đăng nhập hợp lệ!'; exit($ajax->toString()); } else { exit('Invalid request!'); } }