Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function register()
- {
- if(isset($_POST['register'])){
- $this->form_validation->set_rules('username','Username','required|is_unique[accounts.Username]');
- $this->form_validation->set_rules('email','Email','required|is_unique[accounts.Email]');
- $this->form_validation->set_rules('nomeforum','nomeforum','required|is_unique[accounts.nomeforum]');
- $this->form_validation->set_rules('password','Password','required');
- //
- if($this->form_validation->run () == true){
- $data = array(
- 'username'=>$_POST['username'],
- 'email'=>$_POST['email'],
- 'nomeforum'=>$_POST['nomeforum'],
- 'password'=>strtoupper(hash('whirlpool',$_POST['password']))
- );
- $this->db->insert('accounts',$data);
- $this->session->set_flashdata('success_msg', 'Sua conta foi criada com sucesso.');
- try {
- $this->send_email($email, $subject, $message)
- } catch (Exception $e) {
- $this->set_error($e->getMessage());
- }
- redirect("painel/register");
- }
- }
- $this->load->view("painel/register");
- }
- public function send_mail($to, $subject, $body, $from = NULL, $from_name = NULL, $attachment = NULL, $cc = NULL, $bcc = NULL) {
- try {
- $mail = new PHPMailer;
- $mail->isSMTP();
- // $mail->SMTPDebug = 1;
- $mail->Host = "smtp.gmail.com";
- $mail->SMTPAuth = true;
- $mail->Username = $emailusername;
- $mail->Password = $emailpassword;
- $mail->Port = 465;
- if ($from && $from_name) {
- $mail->setFrom($from, $from_name);
- $mail->setaddReplyToFrom($from, $from_name);
- } elseif ($from) {
- $mail->setFrom($from, $this->site_name);
- $mail->addReplyTo($from, $this->site_name);
- } else {
- $mail->setFrom($this->default_email, $this->site_name);
- $mail->addReplyTo($this->default_email, $this->site_name);
- }
- $mail->addAddress($to);
- if ($cc) { $mail->addCC($cc); }
- if ($bcc) { $mail->addBCC($bcc); }
- $mail->Subject = $subject;
- $mail->isHTML(true);
- $mail->Body = $body;
- if ($attachment) {
- if (is_array($attachment)) {
- foreach ($attachment as $attach) {
- $mail->addAttachment($attach);
- }
- } else {
- $mail->addAttachment($attachment);
- }
- }
- if (!$mail->send()) {
- throw new Exception($mail->ErrorInfo);
- return FALSE;
- }
- return TRUE;
- } catch (phpmailerException $e) {
- throw new Exception($e->errorMessage());
- } catch (Exception $e) {
- throw new Exception($e->getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement