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 register() { if ($this->input->is_ajax_request()) { $data = $this->input->post(); $ajax = new AjaxResponse(); if (Public_class::isValidEmail($data['email']) != 1) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-email'; $ajax->message = 'Email không hợp lệ!'; exit($ajax->toString()); } $user = $this->db->get_where('users', array('email' => $data['email'])); if ($user->num_rows() > 0) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-email'; $ajax->message = 'Email đã tồn tại!'; exit($ajax->toString()); } if (Public_class::isValidUsername($data['username']) != 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()); } if ($this->_inValidUsername($data['username']) != 1) { $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()); } $user = $this->db->get_where('users', array('username' => $data['username'])); 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()); } if (strlen($data['password']) < 6) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-password'; $ajax->message = 'Mật khẩu từ 6 ký tự trở lên!'; exit($ajax->toString()); } if ($data['password'] != $data['repassword']) { $ajax->type = AjaxResponse::ERROR; $ajax->element = 'error-repassword'; $ajax->message = 'Mật khẩu xác nhận không khớp!'; exit($ajax->toString()); } unset($data['repassword']); $data['username'] = strtolower($data['username']); $id_log = $this->_save($data); if ($id_log > 0) { $this->auth->login($id_log, FALSE); $ajax->type = AjaxResponse::SUCCESS; $ajax->element = 'success'; $ajax->message = 'Trong 3-5 phút tới bạn sẽ nhận được một email tới ' . $data['email'] . ' Vui lòng kiểm tra hòm mail để kích hoạt tài khoản. Rất có thể mail đã bị gửi vào mục Spam/Junk Mail, hãy kiểm tra 2 mục này nếu bạn không thấy mail của chúng tôi. Xin cảm ơn!'; exit($ajax->toString()); } $ajax->type = AjaxResponse::WARNING; $ajax->element = 'WARNING'; $ajax->message = 'Hiện tại không thể đăng ký, vui lòng liên hệ với bộ phận CSKH để được giúp đỡ!'; exit($ajax->toString()); } else { exit('Invalid request!'); } }