<?php

if(!defined('BASEPATH')) exit ('no direct script access');

class Mypages extends CI_Controller{

    function  __constract(){

        parent::__construct();

        if(!($this->session->userdata('language'))){

            $this->session->set_userdata('language','english');

        }
    }

    function  index(){

        $this->load->view('include_view_header');
        $this->load->view('view_mypages');
        $this->load->view('includes/view_footer');
    }




function createpost()
{

    $this->load->liblary('form_validation');
    $this->load->model('model_message');

    $this->form_validation->set_rules('sender_name', 'Name', 'required|max_length[50],xss_clean|alpha_dash');
    $this->form_validation->set_rules('sender_message', 'Message', 'required|max_length[10],xss_clean|alpha_clean');

    if ($this->load->validation->run() == FALSE) {

        $this->load->view('include_view_header');
        $this->load->view('view_mypages');
        $this->load->view('includes/view_footer');
    } else {

        if ($this->input->post('language') == 'english') {

            $this->session->set_userdata('language', 'english');
        } else if ($this->input->post('language') == 'french') {
            $this->session->set_userdata('language', 'french');

        }

    }



    $data=array();

        $sender=$data['sender']=$this->input->post('sender_name');

        $message=$data['message']=$this->input->post('sender_message');
$inserted=$this->model->message->insert_messag($sender,$message);

    if($inserted){
        $this->load->view('includes/view_header');
        $this->load->view('view_message_sent');
        $this->load->view('includes/view_footer');
    }

}

    
}


?>