0

So I'm editing one of my company's websites. I am not all too familiar with the way Zend works, but I haven't had good luck finding a solution to this problem.

We have two different sites, a staging website which I freely edit and test on, and a live version that the public can view. When I created a new controller/view, I used $_GET data to handle some forms. It worked as expected on the testing end, but the production end for some reason didn't work. After a bit of testing, I found out that the $_GET data is not actually being sent, and thus my script would boot me out (as it is designed to).

The URL looks sorta like this:

/admin/something/update?data=20

So I check the $_GET as I usually do:

if ( isset($_GET) && !empty($_GET["data"]) ) {
  // do something
} else {
  // redirect the user
}

It always redirects like it should if there is no $_GET data (and if data doesn't contain a value).

So I debug and find out that this is what $_GET looks like after I print_r and all I get is an empty array despite the URL clearly containing the $_GET data.

It might be my limited knowledge of Zend handles GET and POST data (because I pretty much keep my edits to old-school PHP), so any light to this would be fantastic. Thanks.

  • I don't know ZF, but if I had to guess I would say that either your mod_rewrite rules don't have the `QSA` flag and so query string items aren't being forwarded or that ZF does something with $_GET, overwrites it and then expects you to use some method to fetch that data. – Jonathan Kuhn Aug 11 '17 at 18:33
  • [You don't need to check both `isset() && !empty()`](https://stackoverflow.com/questions/4559925/why-check-both-isset-and-empty). – Qirel Aug 11 '17 at 18:34
  • `$_GET` as other **superglobals** is always\ available, so checking if it exists is pointless – Marcin Orlowski Aug 11 '17 at 19:02
  • I've been using isset() and !empty() for virtually everything, so even when it comes to dealing with the superglobals. – Christopher 'Solidus' DeJong Aug 11 '17 at 21:35

1 Answers1

1

It seems some problem into your .htaccess file. May be some additional rewrite rule for SEO.

you can add and try with, either should work,

RewriteRule . index.php?url=$1 [PT,L,QSA]

Or,

RewriteRule ^(.*)$ %{ENV:BASE}/index.php [L]

and for getting get value, you should use,

 if(isset($_GET['data']) && $_GET['data']){
            var_dump($_GET['data']);exit;
        }
Gautam Rai
  • 2,445
  • 2
  • 21
  • 31