Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4586278
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:36:59+00:00 2026-05-21T21:36:59+00:00

I have a div containing a search box: <div id=searchbox> <?php echo form_open(‘places/search/sort_by/id/sort_order/desc/term/’.$this->input->post(‘term’)); ?>

  • 0

I have a div containing a search box:

<div id="searchbox">
    <?php echo form_open('places/search/sort_by/id/sort_order/desc/term/'.$this->input->post('term')); ?>
        <?php echo form_label('Search for', 'term'); ?>
        <?php echo form_input('term', set_value('term'), 'id="term"'); ?>
        <?php echo form_submit('submit', 'Search'); ?>
    <?php echo form_close(); ?>
</div>

In the input the user can type in a search term, which will be given to the controller using $this->input->post(‘term’) which then passes to the model to query the database. Now after typging in the search term and submitting the form, I want the url to end with the search term ie. places/search/sort_by/id/sort_order/desc/term/dinosaur if ‘dinosaur’ was the search term. How can I do this?

Right now the code above passes the POST to controller, but the url right after submitting the form is just places/search/sort_by/id/sort_order/desc/term/. Then if the user searches for another term say ‘cats’, after submitting the url becomes places/search/sort_by/id/sort_order/desc/term/dinosaur when the search term is actually ‘cats’.

How can I solve this?

In other words, this is the behavior i want

  1. URL is places/search/sort_by/id/sort_order/desc/term/ and search box is empty
  2. ‘Dinosaur’ is typed into search box, and press submit
  3. URL is now places/search/sort_by/id/sort_order/desc/term/dinosaur and search box contains ‘dinosaur’
  4. ‘cats’ is typed into search box, and press submit
  5. URL is now places/search/sort_by/id/sort_order/desc/term/cats and search box contains ‘cats’

This is what I am getting with the above code

  1. URL is places/search/sort_by/id/sort_order/desc/term/ and search box is empty
  2. ‘Dinosaur’ is typed into search box, and press submit
  3. URL is now places/search/sort_by/id/sort_order/desc/term/ and search box contains ‘dinosaur’

  4. ‘cats’ is typed into search box, and press submit

  5. URL is now places/search/sort_by/id/sort_order/desc/term/dinosaur and search box contains ‘cats’
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:36:59+00:00Added an answer on May 21, 2026 at 9:36 pm

    Try this…

    <div id="searchbox">
        <?php echo form_open('places/search/sort_by/id/sort_order/desc/term/'); ?>
            <?php echo form_label('Search for', 'term'); ?>
            <?php echo form_input('term', set_value('term', $term), 'id="term"'); ?>
            <?php echo form_submit('submit', 'Search'); ?>
        <?php echo form_close(); ?>
    </div>
    

    Then in the controller that accepts it…

                          // Note the default NULL value for the last uri segment
                         //                                                   |
                        //                                                    v
    function search($sort_by, $id, $sort_order, $desc, $term, $search_term = NULL)
    {
         // if $search_term is null redirect on itself concating the "post" data 
        // on the end of the uri
        if ($search_term === NULL) 
        { 
            redirect('the/same/uri/plus/the/term/'.$this->input->post('term'));
        }
    
        // load up this variable to fill the input
        $data['term'] = $search_term;
    
        //then do whatever
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a modal dialog box which is containing search field. when I select
I have a DIV containing an image and a second DIV. The parent DIV
So I have a Div containing an iframe that I can Clone using JQuery.
Hey so I have a div containing 3 links which have a background url
I have a div element containing some text. When the user clicks a word
I have a div, containing text and a few links. I want to trigger
So I have 3 divs contained inside a containing div like such: <div id=contain>
I have 2 divs, 70% and 30% widths, within a 100% width containing div.
I have a div containing li's and a div containing a table. When there
I have a div containing several other divs with setting float:left. Now I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.