Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function check_pay_email()
- {
- $data = array('status' => 'error');
- try {
- $this->load->model('user_model');
- $pay_email = $this->input->post('pay_email', true);
- if (!filter_var($pay_email, FILTER_VALIDATE_EMAIL) OR
- strlen($pay_email) > 255) {
- throw new Exception("Incorrect email", 1);
- }
- $pass = $this->input->post('pass', true);
- if (NULL == $pass OR strlen($pass) > 36 OR strlen($pass) <= 4) {
- throw new Exception("Incorrect length of password", 1);
- }
- $pay_type = $this->input->post('pay_type', true);
- $id = $this->userID;
- $user = $this->user_model->getByID($id);
- if ($user) {
- if ($user['pass'] == doPasswordHash($pass, $user['email'])) {
- $params['pay_email'] = $pay_email;
- $params['pay_type'] = $pay_type;
- $this->db->where('id_user', $id);
- $res = $this->db->update('users', $params);
- //return true;
- } else throw new Exception("Password error");
- }
- $data['status'] = 'done';
- } catch (Exception $e) {
- $data['status'] = 'error';
- $data['message'] = $e->getMessage();
- $data['code'] = $e->getCode();
- }
- echo json_encode($data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement