<?php
class Careers_model extends CI_Model {
public function __construct(){
$this->load->database();
}
public function cvcareers($vars){
//getting values from the submitted form
$designation = $_POST['career-designation'];
$email = $_POST['career-email'];
$name = $_POST['career-name'];
$number = $_POST['career-number'];
$msg = $_POST['career-msg'];
$cvdata = '';
//Uploading file to the directory
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = 1000;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile'))
{
$vars['cv_status']= array('error' => $this->upload->display_errors());
print_r($vars);
echo 'Uploaderror';
}
else
{
$cvdata= $this->upload->data();
//assiging form data in array to pass to the database function
$data = array(
'designation' => $designation,
'email' =>$email,
'name'=>$name,
'number'=>$number,
'message'=>$msg,
'path'=>$config['upload_path'],
//'cv' =>$cvdata['file_name'],
'cv' =>'filename',
);
//Inserting data into the database
$this->db->insert('careers', $data);
//Genrating email for sending,
$mailconfig['protocol'] = 'smtp';
$mailconfig['smtp_host'] = 'ssl://smtp.gmail.com'; //change this
$mailconfig['smtp_port'] = '465';
$mailconfig['smtp_user'] = '@gmail.com'; //change this
$mailconfig['smtp_pass'] = ''; //change this
$mailconfig['mailtype'] = 'html';
$mailconfig['charset'] = 'iso-8859-1';
$mailconfig['wordwrap'] = TRUE;
$mailconfig['newline'] = "\r\n";
$this->load->library('email',$mailconfig);
$subject="CV";
//Genrating email template by entered user data
$message =message($designation,$email,$name,$number,$msg,$cvdata);
//attaching file with the email
$this->email->attach($cvdata["full_path"]);
$this->email->set_newline("\r\n");
$this->email->set_mailtype("html");
$this->email->from('@gmail.com');
$this->email->to('@gmail.com');
$this->email->subject($subject);
$this->email->message($message);
if($this->email->send())
{
echo 'Emailsent';
}
else
{
//show_error($this->email->print_debugger());
$emailerror=$this->email->print_debugger();
}
}
}
}