title: Server side scripting onkeyup PHP
body: <p>i am trying to make an search box which search the name from elastic search database, but when i run the it always give me an error that ----</p>
  
  <p><strong>Notice: Undefined index: value in the line --> $query = $_GET['search_keyword'];</strong></p>
  
  <p>but from my script i believe it should get the "search_keyword".</p>
  
  <p><strong>Search box --</strong></p>
  
  <pre><code>&lt;form method="GET" action="/latest/helloTestData"&gt;
  
      &lt;input type="text" name="sample_search" id="sample_search" onkeyup="search_func(this.value);"&gt;
  
  &lt;/form&gt;
  </code></pre>
  
  <p>Script --</p>
  
  <pre><code>    &lt;script&gt;
         $(function () {
      var minlength = 3;
  
      $("#sample_search").keyup(function () {
          var that = this,
          value = $(this).val();
  
          if (value.length &gt;= minlength ) {
              $.ajax({
                  type: "GET",
                  url: "/latest/helloTestData", // address to the php function
                  data: {
                      'search_keyword' : value
                  },
                  dataType: "text",
                  success: function(msg){
                      //we need to check if the value is the same
                      if (value==$(that).val()) {
                      //Receiving the result of search here
                      }
                  }
              });
          }
      });
  }); 
      &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP ---</strong></p>
  
  <pre><code>public function helloTestDataAction() {
  
          $paramss = array('hosts' =&gt; array('localhost:9200'));
          $client = new Elasticsearch\Client($paramss); 
  
          $query = $_GET['search_keyword'];
          if ($query != "") {
  
          $params = array();
          $params['size'] = 1000000000;
          $params['index'] = 'myindex';
          $params['type'] = 'mytype';
          $params['body']['query']['bool']['must'] = array(
              array('match' =&gt; array('name' =&gt; $query)), // search data by input data
          );
  
          $esresult = $client-&gt;search($params);
  
              if ($esresult &lt; 1) {
                  echo "Your search did not match any documents. Please try different keywords.";
              } else {
                                  echo $esresult; //results found here and display them
              }
              }
  
               return new Response('ok');
      }
  </code></pre>
  
  <p>Can anyone knows how to fix this problem. Thanks a lot in advanced.</p>