public function add($table) { if (!$this->form_validation->run('admin_add_' . $table)) { $this->load->view('admin/add_' . $table); } else { if ($table == 'blog_posts') { $this->load->model('blog_post'); $post = new Blog_Post(); $post->subject = $this->input->post('subject'); $post->body = $this->input->post('body'); $post->headline = $this->input->post('headline'); $post->last_edit = date("Y-m-d H:i:s"); $post->save(); $this->session->set_flashdata('edit', "Blog post added!"); } else { if ($table == 'content_pages') { $this->load->model('content_page'); $page = new Content_Page(); $page->name = $this->input->post('name') . $this->input->post('type'); $page->body = $this->input->post('body'); $page->last_update = date("Y-m-d H:i:s"); $page->creation_date = date("Y-m-d H:i:s"); $page->save(); $this->session->set_flashdata('edit', "Content page added!"); } else { if ($table == 'admin_users') { $this->load->model('admin_user'); $user = new Admin_User(); $user->username = $this->input->post('add_username'); $user->password = md5($this->input->post('add_password')); $user->creation = date("Y-m-d H:i:s"); $user->save(); $this->session->set_flashdata('edit', "User added!"); } } } redirect('admin/' . $table); } $this->load->view('admin/footer'); }