noviceRick
noviceRick

Reputation: 121

search form codeigniter GET_POST

Here I ant desired url like in php but how can I code this in codeigniter with controller, model, and view? someone has a code with this?

http://mysite.com/search?query=batman&cat=movie

My Controller

function index(){
//some code to get search query value
}

My Model

function getSearch(){
//some code to get search value
}

My View

<form action="http://mysite.com/search/'; ?>">
   <input name="query" value="">
   <input name="cat" value="">
   <input type="submit">
</form>

I want also to retrieve the seesion in text field after submitting.

Upvotes: 0

Views: 898

Answers (1)

Kugutsumen
Kugutsumen

Reputation: 600

  1. You should specify the method of the form
    e.g.
    <form action="http://mysite.com/search/" method="post">
  2. use this to fetch the record
    $query = $this->input->post('query');
    $cat = $this->input->post('cat');

  3. In order to retrieve the type text in to the text field, use set_value
    e.g.
    <input name="query" value="<?php set_value('cat') ?>">
    <input name="cat" value="<?php set_value('query') ?>">

hope this helps!

Upvotes: 1

Related Questions