se memorizza i dati senza immagine, allora
public function create() {
//check if user is logged in
if (!$this->session->userdata('logged_in')) {
redirect('users/login');
}
$this->form_validation->set_rules('mjestoPolaska', 'Mjesto Polaska', 'required');
$this->form_validation->set_rules('mjestoOdredista', 'Mjesto Odredista', 'required');
$this->form_validation->set_rules('datumPolaska', 'Datum Polaska', 'required');
$this->form_validation->set_rules('datumPovratka', 'Datum Povratka', 'required');
$this->form_validation->set_rules('cijena', 'Cijena', 'required');
$this->form_validation->set_rules('brojMjesta', 'Broj mjesta', 'required');
$this->form_validation->set_rules('opis', 'Opis', 'required');
$data['title'] = 'Create Posts';
$data['categories'] = $this->Posts_model->get_categories();
if ($this->form_validation->run() === FALSE) {
$this->session->set_flashdata("error", validation_errors());
$this->load->view('templates/header');
$this->load->view('posts/create', $data);
$this->load->view('templates/footer');
} else {
$post_image='';
if (!empty($_FILES['userfile']['name'])) {
$path = 'assets/images/posts/';
$post_image = $this->ImageUpload($path, 'userfile', '');
if (!is_array($post_image)) {
$this->session->set_flashdata('error', $post_image);
redirect(site_url() . 'posts/create');
}
$post_image = $post_image['file_name'];
}
$this->Posts_model->create_post($post_image);
$this->session->set_flashdata('post_creted', 'You post has been created');
redirect('posts');
}
}