1

First, relevant code:


View

<div id="search">
    <?= form_open('sheet/search') ?>

    <?= form_input('search_query', '', 'id="search_query" placeholder="Search Sheet Music"') ?>
    <?= form_submit('submit', 'Search!', 'class="hidden"') ?>

    <?= form_close() ?>
</div>

Controller sheet/search

public function search()
{
    if ($this->input->post('search_query'))
    {
    // blah
    // [ ... ]

$_POST is completely empty.


What on earth? The annoying thing is, other forms work perfectly fine on my website. Furthermore, this works perfectly on my testing server... so I'm guessing there's something wonky with my configuration files, .htaccess, or something. However, I don't know what could be causing it.

If you have an idea and need more information, feel free to specify. I just have no idea where to look, or what to change! Any help would be hugely appreciated.

Thanks!


EDIT 1/8/2013

Okay, I made a discovery. When my index page is removed from config/config.php, the search does not work. However, when it is added, it DOES work.

It still doesn't make any sense.

Below is my .htaccess file. Think I need to modify it somehow? I have absolutely no idea why it's not working still, but this is a step in the right direction.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|assets|sheet|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
16
  • You should not use "<?="... Commented Jan 7, 2013 at 18:30
  • 1
    @SureshKamrushi It's auto-enabled in PHP 5.4 and CodeIgniter auto-rewrites them if necessary. Commented Jan 7, 2013 at 18:31
  • How do you know that $_POST is completely empty? Do you var_dump($_POST)? Commented Jan 7, 2013 at 18:32
  • 1
    I ran into an issue like this once and it was annoyingly simple. For some reason on my production server I had to include the www as part of the url where the form was posting to, other wise a 302 redirect was clearing the post array. Commented Jan 7, 2013 at 20:43
  • 1
    Are you doing some kind of routing for the sheet/search controller? I noticed if you add the search query as a paramater to the URL. Like so: http://apollomix.com/sheet/search/world The controller seems to work fine. Which could mean your routes need amending. Commented Jan 8, 2013 at 1:20

1 Answer 1

3

AHA, I got it!

The problem was pretty sneaky. Apparently, because my .htaccess file was excepting the sheet directory, AND the controller had the same name, things were going screwy with the CodeIgniter paths. What, exactly, I don't know. But it was bad, apparently!

To anyone in the future with this problem... make sure your .htaccess file isn't messing with your controllers!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.