title: PHP unable to get parameter from URL
body: <p>for some strange reason I'm unable to get GET value from URL</p>
  
  <pre><code>$URL=localhost/supplies/cartridges/?Brand%5B%5D=HP
  </code></pre>
  
  <p>Here's I'm going to check get but this return an empty array</p>
  
  <pre><code> public function getGetparameters(){
      $get=$_GET;
      var_dump($get);
  }
  </code></pre>
  
  <p>var_dump returns next:</p>
  
  <pre><code>array(0) { }
  </code></pre>
  
  <p>I cannot understand why as this </p>
  
  <pre><code>$URL=$_SERVER['REQUEST_URI'];
      $parsedURL=parse_url($URL);
      $URLQ=$parsedURL['query'];
      echo $URLQ;
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>Brand%5B%5D=HP
  </code></pre>
  
  <p>Unfortunatelly I need to use get Parameters so I've stuck a bit :(</p>
  
  <p>Code that generating get:</p>
  
  <pre><code>&lt;form action="" method="get"&gt;&lt;h4&gt;Brand:&lt;/h4&gt;&lt;div class="input-control checkbox"&gt;
                &lt;label&gt;
                &lt;input name="Brand[]" type="checkbox" value="HP"&gt;
                  &lt;span class="check"&gt;&lt;/span&gt;HP&lt;/label&gt;
                &lt;/div&gt;
                 &lt;button type="submit" class="bg-darkCobalt" style="box-shadow: 0 0 3px 0 #000000; color: #ffffff"&gt;&lt;i class="icon-list on-left fg-white"&gt;&lt;/i&gt;Filter&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I'd like simply to replace Brand[] to Brand but later I will add some more brands and I need to maintain those simultaneously, so this is not solution </p>
  
  <p>As I was asked to paste whole class here's it is. PS: Sorry for russian/ukrainian characters :) </p>
  
  <pre><code>class CatalogHandler extends generalRenderer{
  public function getCatalogName(){
      $URL=$_SERVER['REQUEST_URI'];
      $parsedURL=parse_url($URL);
      $URLPath=$parsedURL['path'];
      $array = explode('/',$URLPath);
      $rev = array_reverse($array);
      $catalog = $rev[1];
      return $catalog;
  }
  public function getGetparameters(){
      var_dump($_GET);
  }
  
  
  
  public function renderTitleAndMetaAndSetHeader($newSQL){
      while($row=$this-&gt;fetchArray($newSQL)){
          echo "&lt;title&gt;".$row['Title']." ".$this-&gt;setSuffix."&lt;/title&gt;
               &lt;meta name='description' content='".$row['Desc']."'/&gt;
               &lt;meta name='keywords' content='".$row['KeyWord']."'/&gt;
          ";
          $this-&gt;setHeader($row['Title']);
      }
  }
  public function getCatalogJS($path,$catalogname){
      echo "&lt;script type='text/javascript' src='".$path."js/".$catalogname.".js'&gt;&lt;/script&gt;";
  }
  public function getFilters($newSQL,$SQL){
      echo "&lt;div class='grid'&gt; &lt;div class='row'&gt;&lt;div class='span3 padding10 border'&gt;
                      &lt;form action='' method='get'&gt;";
      $this-&gt;getBrands($newSQL);
      $this-&gt;getTypes($SQL);
      echo "&lt;div class='clearfix'&gt;&lt;/div&gt;
      &lt;button type='submit' class='bg-darkCobalt' style='box-shadow: 0 0 3px 0 #000000; color: #ffffff'&gt;&lt;i class='icon-list on-left fg-white'&gt;&lt;/i&gt;Фильтровать&lt;/button&gt;
      &lt;/form&gt;
      &lt;/div&gt;";
  }
  public function checkedBrandAndFilter($row){
      if(!empty($_GET['Brand'])&amp;&amp;in_array('HP',$_GET['Brand'])){
          echo "checked='checked'";
      }
      else{
          echo "";
      }
  }
  public function checkedTypeAndFilter($row){
      if(!empty($_GET['Type'])&amp;&amp;in_array($row['Type'],$_GET['Type'])){
          echo "checked='checked'";
      }
      else{
          echo "";
      }
  }
  public function getBrands($newSQL){
      echo "&lt;h4&gt;Brand:&lt;/h4&gt;";
      while($row=$this-&gt;fetchArray($newSQL)){
          echo "&lt;div class='input-control checkbox'&gt;
                &lt;label&gt;
                &lt;input name='Brand[]' type='checkbox' value='".$row['Brand']."'";
                 if(!empty($_GET['Brand'])&amp;&amp;in_array('HP',$_GET['Brand'])){
                      echo "checked='checked'";
                 }
                  else{
                      echo "checked=''";
                      echo $_GET['Brand'];
                  }
                echo "/&gt;
                  &lt;span class='check'&gt;&lt;/span&gt;".$row['Brand']."&lt;/label&gt;
                &lt;/div&gt;
          ";
      }
  }
  public function getTypes($SQL){
      echo "&lt;h4&gt;Тип:&lt;/h4&gt;";
      while($row=$this-&gt;fetchArray($SQL)){
          echo "&lt;div class='input-control checkbox'&gt;
                &lt;label&gt;
                &lt;input name='Type[]' type='checkbox' value='".$row['Type']."'
                 ".$this-&gt;checkedTypeAndFilter($row)."/&gt;
                  &lt;span class='check'&gt;&lt;/span&gt;".$row['Type']."&lt;/label&gt;
                &lt;/div&gt;
          ";
      }
  }
  public function getProductNameModelAndLink($row){
      echo "&lt;a href='".$row['Brand']."-".$row['Model']."'&gt;&lt;h4&gt;".$row['Brand']." ".$row['Model']."&lt;/h4&gt;&lt;/a&gt;";
  }
  public function getProductIMG($row){
      echo "&lt;a href='".$row['Brand']."-".$row['Model']."'&gt;
                  &lt;img class='span2 shadow' src='".$row['IMGPath']."' alt='".$row['Brand']." ".$row['Model']." купить и провести сервисное обслуживание в Житомире и области'/&gt;
            &lt;/a&gt;";
  }
  public function getBrand4Tech($row){
      if(isset($row['Brand'])){
      echo "Производитель: ".$row['Brand']." / ";
      }
      else{
      }
  }
  public function getModel4Tech($row){
      if(isset($row['Model'])){
          echo "Модель: ".$row['Model']." / ";
      }
      else{
      }
  }
  public function getType4Tech($row){
      if(isset($row['Type'])){
          echo "Тип: ".$row['Type']." / ";
      }
      else{
      }
  }
  public function getCode4Tech($row){
      if(isset($row['Code'])){
          echo "Код: ".$row['Code']." / ";
      }
      else{
      }
  }
  public function getProductTechInfo($row){
      $this-&gt;getBrand4Tech($row);
      $this-&gt;getModel4Tech($row);
      $this-&gt;getType4Tech($row);
      $this-&gt;getCode4Tech($row);
  }
  public function renderProducts($SQL,$catalogname){
      echo "&lt;div class='span9'&gt;";
      while($row=$this-&gt;fetchArray($SQL)){
          $this-&gt;getProductNameModelAndLink($row);
          $this-&gt;getProductIMG($row);
          echo "&lt;div class='span7'&gt;";
          $this-&gt;getProductTechInfo($row);
          $this-&gt;renderPrice($row);
          $this-&gt;getBuyButton($catalogname,$row);
          $this-&gt;renderStock($row);
          echo "&lt;/div&gt;";
  
                      echo "&lt;div class='clearfix'&gt;&lt;/div&gt;";
      }
      echo "&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;";
  }
  }
  </code></pre>
  
  <p>And this how it is used:</p>
  
  <pre><code>&lt;?php
  include('CatalogHandler.php');
  include('DBconfig.php');
  
  $config = new DBconfig('localhost','setuser','a11235813b','setua');
  $con=mysqli_connect('localhost','setuser','a11235813b','setua');
  $catalog = new CatalogHandler($config);
  $catalogname=$catalog-&gt;getCatalogName();
  
  $catalog-&gt;openConnection();
  $query="SELECT * FROM metaandtitlecatalogs WHERE Cat='".$catalogname."'";
  $query4brands="SELECT DISTINCT(Brand) AS Brand FROM ".$catalogname;
  $query4types="SELECT DISTINCT(Type) AS Type FROM ".$catalogname;
  $query4catalog="SELECT * FROM ".$catalogname;
  
  $catalog-&gt;startHead('../../');
  $catalog-&gt;getGetparameters();
  $result = mysqli_query($con,$query);
  $result4brands=mysqli_query($con,$query4brands);
  $result4types=mysqli_query($con,$query4types);
  $result4catalog=mysqli_query($con,$query4catalog);
  
  $catalog-&gt;renderTitleAndMetaAndSetHeader($result);
  $catalog-&gt;getGenCSS('../../');
  $catalog-&gt;getGenJS('../../');
  $catalog-&gt;getJS4Filters('../../');
  $catalog-&gt;getCatalogJS('../../',$catalogname);
  $catalog-&gt;closeHead();
  $catalog-&gt;getTopBarAndStartBody('../../');
  $catalog-&gt;getHeader();
  $catalog-&gt;getFilters($result4brands,$result4types);
  $catalog-&gt;renderProducts($result4catalog,$catalogname);
  $catalog-&gt;getGetparameters();
  ?&gt;
  </code></pre>
  
  <p><strong>UPDATES:</strong>
  I have single script in /setua/catalogues.php
  everything from /setua/supplies/* is redirected to catalogues.php.
  Path after supplies defines MySQL table to connect with.
  In case i specify form action to</p>
  
  <pre><code> $_SERVER['PHP_SELF']
  </code></pre>
  
  <p>it redirects to URL /setua/catalogues.php so connection to required DB is lost. But then GET parameters are recognized OK. But as soon as URL /setua/supplies/* is specified in form action - GET parameters are lost </p>
  
  <p><strong>ERROR FOUND</strong>
  If you are using $_GET it will only work from the initial page to the next page UNLESS you manually add the GET variables back into any redirects. Sounds like you are submitting your form to a page that redirects elsewhere which looses the $_GET variables.</p>