Welcome Guest, Not a member yet? Register   Sign In
Search Criteria Ignored, Only Redirects to Else Statement
#9

(This post was last modified: 06-13-2019, 11:46 AM by Josh1985.)

(06-13-2019, 09:56 AM)jreklund Wrote: In that case change ALL your $this->input->post('submit') into $this->input->method() === 'post' instead.
You aren't sending any data inside your submit button, so it will always be null.

Not sending data:
<input type="submit" value="Submit!" />

Sending data:
<input type="submit" name="submit" value="Submit!" />

Or you can do $this->input->post() instead. Depending how you would like to validate that all your fields have been submitted.

Hmm, if what you suggest is accurate then why is it that ALL my other form submits work just fine. Like sending data to the database, just not my search function?

Also, as far as "sending data"... I am not sure what you mean by that. I am not aware I was "sending" anything. The search is supposed to be a simple query of the database and return a view for the result. So what exactly am I supposed to be sending? If I am not mistaken the Else statement was originally written as more of a debugging protocool to alert to something not working correctly visually rather than as an error. Any thoughts there?

For example, I tried the following corrections:

Modified Function #1:
Code:
function search(){
if ($this->input->method() === 'post'
    $search = $this->input->post('query');
   $results = $this->recipe_model->search($search);
      $data = array(
          'title' => "Shirley's Recipes : Search Results",
      'columns' => array('toc', 'recipe_search'),
      'recipes' => $results,
   );
   $this->load->view('includes/template', $data);
   }
   else{
    redirect('recipe');
   }
}

Result #1:
Code:
An uncaught Exception was encountered

Type: ParseError

Message: syntax error, unexpected '$search' (T_VARIABLE)

Filename: /home/www/shirleysrecipes.100webspace.net/application/controllers/Recipe.php

Line Number: 55

Backtrace:

File: /home/www/shirleysrecipes.100webspace.net/index.php
Line: 315
Function: require_once

Please make no mistake, if your suggestion is my fix for this issue I will happily implement it but I am confused as to why only 1 out of approximately 4 form submits has this issue?

Thank you again!
Reply


Messages In This Thread
RE: Search Criteria Ignored, Only Redirects to Else Statement - by Josh1985 - 06-13-2019, 11:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB