public function dathen() { if ($type = $this->input->get('type')) { if ($type == 'form') { $this->session->set_userdata('token_dathen_client', base64_encode(substr(sha1(time() . 'monster'), 0, 6))); $this->load->view('components/popup_dat_hen'); } else { if ($type == 'token') { echo $this->session->userdata('token_dathen_client'); } } } if ($this->input->post('token') == $this->session->userdata('token_dathen_client')) { if (preg_match('/^[0-9]{10,11}$/', $this->input->post('dienthoai'))) { $benhdb = new BenhtvDB(); $benhdb->saveDatHen($this->input->post()); $this->session->unset_userdata('token_dathen_client'); $dataMenu['message'] = 'Đặt hẹn khám thành công.'; $dataMenu['error'] = false; } else { $dataMenu['message'] = 'Số điện thoại không hợp lệ. Vui lòng nhập lại số điện thoại.'; $dataMenu['error'] = true; } echo json_encode($dataMenu); } return false; }