Question: This is my controller

```
function new_post(){
    if($_POST){
        $data=array(
            'title'=>$_POST['title'],
            'post'=>$_POST['post'],
            'active'=>1);
    $this->post->insert_post($data);
    redirect('post/');
    } 
    else {
        $this->load->view('new_post');
    }
}

```

This is not working is this controller fine,
**model**
this is the model only it inserts to the form.

```
  function insert_post($data){
        $this->db->insert('posts',$data);
        return $this->db->insert_id();
    }

```

If I change this to 

```
                  $data=array(
                'title'=>$_POST['title'],
                'post'=>$_POST['post'],
                'active'=>1);
              $this->post->insert_post($data);

```

Then it works 

Have I did any mistake on first controller because it's not inserting....

Regards

Answer: 
Try changing the condition to this, to see if the values have been set:

```
if(isset($_POST['title']) && isset($_POST['post']))
{ ...

```

I'd also ensure that you are loading your [model](http://ellislab.com/codeigniter/user-guide/general/models.html), are referring to it correctly.

---

In CodeIgniter, the [Input class](http://ellislab.com/codeigniter/user-guide/libraries/input.html) allows you to access `POST` data using this function:

```
$this->input->post('title');

```

as an alternative to this:

```
$_POST['title'];

```

There are some differences, which are explained in the documentation.
Try to replace

```
redirect('post/');

```

with

```
header('Location:your_url');

```

redirect will immidiately redirects you without knowing the previous statement has executed ot not but a header(); will do that

I think it is causing the problem