<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Add_SMTP_Controller extends CI_Controller {

	public function Add_Smtp_View()
	{
        $this->load->view('Add_SMTP_View'); 
    }
    
    public function Add_Smtp_Data()
	{
        $this->load->library('form_validation');
        $this->form_validation->set_rules('protocol', 'text', 'required');
        $this->form_validation->set_rules('host', 'text', 'required');
        $this->form_validation->set_rules('port', 'text', 'required');
        $this->form_validation->set_rules('username', 'text', 'required');

        if($this->form_validation->run())
        {
            $protocol=$this->input->post('protocol');
            $security=$this->input->post('security');
            $host=$this->input->post('host');
            $port=$this->input->post('port');
            $username=$this->input->post('username');
            $password=$this->input->post('password');
                        
            $edit_data['protocol']=$protocol;
            $edit_data['security']=$security;
            $edit_data['host']=$host;
            $edit_data['port']=$port;
            $edit_data['username']=$username;
            $edit_data['password']=$password;

            $this->load->model('Add_Data');
            if($this->Add_Data->Insert_Data_SMTP($edit_data))
                {
                    //echo "Inserted";
                    $this->session->set_flashdata('smtp_added','SMTP added Successfully');
                    redirect(base_url().'index.php/Add_SMTP_Controller/Add_Smtp_View');
                }
                else
                {
                    //echo "Not Inserted";
                    $this->session->set_flashdata('zone_added','Zone not added');
                    redirect(base_url().'index.php/Add_SMTP_Controller/Add_Smtp_View');
                }
        }
    }
}

