CodeIgniter Forums
Form Submitting Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Submitting Problem (/showthread.php?tid=41129)



Form Submitting Problem - El Forum - 04-28-2011

[eluser]Isuru[/eluser]
I created this form.

Code:
<!-- Search -->
        <div id="search" class="noprint">
            &lt;?php
            echo form_open("/index.php/welcome/search");
            $data = array("name" => "term","id" => "term","maxlength" => "64","size" => "30");
            echo form_input($data);
            echo form_submit("submit","search");
            echo form_close(); ?&gt;
        </div> &lt;!-- /search --&gt;

And this is the model

Code:
function search($term){
        $data = array();
        $this->db->select('id, title, shortdesc');
        $this->db->like('title', $term);
        $this->db->or_like('shortdesc', $term);

        $this->db->order_by('title');
        $this->db->where('status', 'active');
        
        $Q = $this->db->get('jobs');
        if($Q -> num_rows > 0){
            foreach($Q->result_array() as $row){
                $data[] = $row;
            }
        }

        $Q -> free_result();
        return $data;

    }

And this is the controller.

Code:
function search(){
        

        $search['results'] = $this->jobs->search($this->input->pos('term'));
        $data['title'] = 'Job Board| Search Results';
        
        $this->load->vars($data);
        $this->load->view('search_result');
    }


But I can't get it to work.
I added 'form' helper to autoload.php

I am new to CI. So please help me.


Form Submitting Problem - El Forum - 04-29-2011

[eluser]InsiteFX[/eluser]
Code:
echo form_open("welcome/search");

InsiteFX


Form Submitting Problem - El Forum - 05-01-2011

[eluser]Isuru[/eluser]
[quote author="InsiteFX" date="1304075079"]
Code:
echo form_open("welcome/search");

InsiteFX[/quote]

I kindly thank you, but can you be more specific.

Where do I put that?


Form Submitting Problem - El Forum - 05-01-2011

[eluser]augustowloch[/eluser]
insitefx meant: your
Code:
form_open
on the view (form) should point to 'welcome/search' instead of '/index.php/welcome/search'

btw, on the controller you're reading the post value with $this->input->pos('term'), maybe a typo, but it should read $this->input->post('term') (is a posT ,not a pos)