• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form Submitting Problem

#1
[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.

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

InsiteFX

#3
[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?

#4
[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)


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.