public function signUp() { $data["success"] = $data["error"] = ""; if (isset($_POST["btnSignUp"])) { $this->form_validation->set_rules('name', "Name", 'required|xss_clean'); $this->form_validation->set_rules('email', "Email", 'required|valid_email|xss_clean'); $this->form_validation->set_rules('username', "Username", 'requiredxss_clean'); $this->form_validation->set_rules('password', "Password", 'required|xss_clean'); $this->form_validation->set_rules('confirm_password', "Confirm Password", 'required|xss_clean'); if ($this->form_validation->run()) { $name = $this->input->post('name', true); $email = $this->input->post('email', true); $username = $this->input->post('username', true); $password = $this->input->post('password', true); $insertArr = array('name' => $name, 'type' => $this->config->item('group_seller'), 'username' => strtolower($username), 'email' => $email, 'password' => md5($password)); if ($this->master_model->addRecord($this->TBL_USERS, $insertArr)) { $user_id = $this->db->insert_id(); $config = email_config(); $this->email->initialize($config); $this->email->from("*****@*****.**", "Trade Plus"); $this->email->to($email); $this->email->set_mailtype("html"); $this->email->subject("Welcome to Trade Plus!"); $this->email->message("Hello " . $username . ",<br><br> Thank you for registering to Trade Plus. Please <a href='" . base_url() . "activate-account/" . base64_encode($user_id) . "'>click here</a> to activate you account!!<br><br> Thank you,<br>Trade Plus Team"); $this->email->send(); $data['success'] = "Registered successfully! Please check your email to activate your account."; } else { $data['error'] = "Problem occured while registering. Please try again later!"; } } else { $data['error'] = $this->form_validation->error_string(); } } $this->load->view('signup', $data); }
public function __construct() { $this->class =& get_instance(); $this->class->load->helper("setup"); $this->class->load->library("email"); if (email_config() != NULL) { $this->class->email->initialize(email_config()); } }
public function Edit() { if (!isset($_REQUEST['txt_nombres'])) { redirect("/0/"); return; } $nombre = $_REQUEST['txt_nombres']; $apellido = $_REQUEST['txt_apellidos']; $correo = $_REQUEST['txt_email']; $pass = isset($_REQUEST['txt_pass']) ? $_REQUEST['txt_pass'] : NULL; $status = isset($_REQUEST['txt_baja']) ? $_REQUEST['txt_baja'] : NULL; $id = $_REQUEST['id_user']; $data_login = array(); $data_user = array("nombres" => $nombre, "apellidos" => $apellido, "email" => $correo); if ($status != NULL) { $data_login["status"] = $status; } if ($pass != NULL) { $this->load->helper("string"); $this->load->library("encryption"); $this->load->helper("setup"); $random = random_string(); $this->encryption->initialize(array('cipher' => 'aes-256', 'mode' => 'cbc', 'key' => get_key())); $data_login['password'] = $this->encryption->encrypt($random); $data_login['password_state'] = 0; $this->load->library("email"); if (email_config() != NULL) { $this->email->initialize(email_config()); } $from_ = email_from(); $this->email->from($from_['from'], $from_['name']); $this->email->to($correo); $this->email->subject('Contraseña Unitee | Inventario'); $message_ = 'Tu nueva contraseña es : ' . $random; $this->email->message($message_); $this->email->send(); } $this->load->model("user/user_edit"); if (count($data_login) >= 1) { $r = $this->user_edit->updateUsers("login", $data_login, "id_login={$id}"); if (!$r) { redirect("/0/user=user_edit?e=3&id=" . $id); return; } } $e = $this->user_edit->updateUsers("user", $data_user, "id_login={$id}"); if ($e) { redirect("/0/user=user_edit?e=0&id=" . $id); return; } else { redirect("/0/user=user_edit?e=3&id=" . $id); return; } }