[eluser]Unknown[/eluser]
Hello, i was following a tutorial from nettuts (CodeIgniter Essentials) and i was making a blog.
Everything worked fine untill i had to make a method to edit posts. This is where the problems appears.
I've followed every single step from the tutorial and i did exactly the same thing but mine is crashing. I've tried to enable the profiler tool but with no luck :/ Im only getting a white screen whenever im submiting the changes.
This is the code from my controller:
Code:
function editpost($postID)
{
$this->output->enable_profiler(TRUE);
$data['success'] = 0;
if($_POST)
{
$data_post = array(
'title' => $_POST['title'],
'post' => $_POST['post'],
'active' => 1
);
$this->post->update_post($postID, $data);
$data['success'] = 1;
}
$data['post'] = $this->post->get_post($postID);
$this->load->view('edit_post', $data);
}
its exactly the same with the tutorial!
The model:
Code:
function update_post($postID, $data)
{
$this->where('postID', $postID);
$this->db->update('posts', $data);
}
And the view is a very simple page:
Code:
<?php if($success == 1): ?>
<div class="success">Post edited successfully</div>
<?php endif; ?>
<form action="<?= base_url(); ?>posts/editpost/<?= $post['postID'] ?>" method="POST">
Title:
<p><input type="text" name="title" value="<?= $post['title'] ?>"></p>
Body:
<p><textarea name="post" cols="30" rows="10"><?= $post['post'] ?></textarea></p>
<p><input type="submit" value="Save post"></p>
</form>
What am i doing wrong? Is there any problem with the version? The guy in the videos is using 2.1 and im using the latest.