Welcome Guest, Not a member yet? Register   Sign In
Problems with crud demo
#1

[eluser]Unknown[/eluser]
Trying to follow this simple crud tutorial: http://fwebde.com/php/simple-crud-with-codeigniter/

Ive only gotten to the first part - Im on 2.0 so Ive updated to 'CI_Model' as appropriate. Looks like its not seeing the model file? Also I have added the php code tags which werent in the demo.

http://www.joe-riggs.com/ci/index.php/crud

FILES:

\ci\application\controllers\crud.php

Code:
<?php

class Crud extends CI_Controller {

    function index() {
        // Check if form is submitted
        if ($this->input->post('submit')) {
            $title = $this->input->post('title');
            $content = $this->input->post('content');

            // Add the post

            $this->posts_model->addPost($title, $content);
        }

        $this->load->view('crud_view');
    }

}

?>

\ci\application\models\posts_model.php

Code:
<?php
class Posts_model extends CI_Model {

    function addPost($title, $content) {
        $data = array(
            'title' => $title,
            'content' => $content
        );

        $this->db->insert('posts', $data);
    }

}

?>

\ci\application\views\crud_view.php

Code:
<?php $this->load->helper('form'); ?>

<?php echo form_open('crud'); ?>

    <p>
        &lt;?php echo form_input('title'); ?&gt;
    </p>

    <p>
        &lt;?php echo form_textarea('content'); ?&gt;
    </p>

    <p>
        &lt;?php echo form_submit('submit', 'Submit'); ?&gt;
    </p>

&lt;?php echo form_close(); ?&gt;


Messages In This Thread
Problems with crud demo - by El Forum - 03-30-2011, 06:10 PM
Problems with crud demo - by El Forum - 04-01-2011, 03:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB