Hello Again,
Yes I am very new to Codeigniter and this depth of PHP.
What my idea is:
My idea is that I can have my url mysite.com/admin/editpage/pagename
which will then bring up the content for that page.
I have produced the following code but I am unsure how to $_POST the data into the form.
Controller
class Editpage extends CI_Controller {
function __construct(){
parent::__construct();
}
function index(){
if($this->session->userdata('logged_in')){
}else{
redirect('admin/home');
}
$page = $this->navigation_model->getCMSPage($this->uri->segment(3));
$data['cms_pages'] = $this->navigation_model->getCMSPages();
$data['title'] = $page->name;
$data['content'] = $this->load->view('admin/editpage', $data);
$this->load->view('admintemplate', $data);
}
}
Model
function getCMSPage($permalink = NULL) {
if(!$permalink) $permalink = 'home'; //Default Page
$this->db->where('permalink', $permalink);
$query = $this->db->get('pages', 1);
if($query->num_rows() == 1) return $query->row();
}
View
<?php
//Setting form attributes
$formpageEdit = array('id' => 'pageEdit', 'name' => 'pageEdit');
$formInputTitle = array('id' => 'title', 'name' => 'title');
$formTextareaContent = array('id' => 'content', 'name' => 'content');
?>
<section id = "validation"><?php echo validation_errors();?></section>
<h4><?= $title ?> </h4>
<?php
echo form_open('admin/editpage/'.$page->permalink, $formpageEdit);
echo form_fieldset();
echo form_label ('Content', 'content');
echo form_textarea('content');
echo form_submit('submit','Submit');
echo form_fieldset_close();
echo form_close();
?>