0

I've been working on a site that passes one information through $_REQUEST. The only reason for that, honestly, is that whenever i try using $_GET or $_POST it returns empty.

So i'm doing this:

<form action="Main.php?short_proj_name=<?= $_REQUEST['short_proj_name']?>" method="post" name="formProjName" target="_blank" id='frmProjName'>

So, this worked perfectly. Got the "Short_proj_name", opened the form, wonderful.

However, due to a couple of changes in the system, i had to tweak my query. It is a very heavy query that gets a lot of information, so it is understandable that it might be a little slow, but after the recent changes, it doesn't even load.

Here is what i changed:

         ".(
                // PROJ_ID
                 !empty($_POST['proj_id'])
                ?   "   AND projetos_main.proj_id in (".implode(",", $_POST['proj_id']) .")"
                :   ""
            )."

So in here i was simply checking if there was a project id, and if it had, it would be part of the query. I had to change it to this:

            ".(
                // PROJ_ID
                 !empty($_POST['proj_id']) && !empty($_GET['proj_id'])
                ?   "   AND projetos_main.proj_id in (".implode(",", $_POST['proj_id']) .")"
                :   ""
            )."

In here both the $_GET and the $_POST must be populated, because the recent changes made it so the $_GET = $_POST.

Now, after that, it doesn't load. It reaches the limit of 200 seconds. It only loads if i take away the $_REQUEST and change it to a $_GET or $_POST.

So, should $_REQUEST really slow the loading down by this much?

RazorFinger
  • 231
  • 2
  • 12
  • Depending on the php.ini, `$_REQUEST` gets filled with the values from `$_GET`, `$_POST` and `$_COOKIE` (by default). http://php.net/manual/en/reserved.variables.request.php – Charlotte Dunois Aug 25 '16 at 18:31
  • Side note: See [SQL Injection](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php). You should always sanitize user input. The user has 100% control of $_REQUEST (and $_POST, $_GET). – noahnu Aug 25 '16 at 18:31
  • 1
    To be absolutely clear: `$_REQUEST` contains nothing except what is also in `$_GET`, `$_POST` and `$_COOKIE`. It is possible to override this behaviour in php.ini, but I have never heard of anyone actually doing so, and in any case, `$_GET` and `$_POST` will still both contain the expected values. All of these, including `$_REQUEST` are just variables. They are all populated when the page is loaded, regardless of whether they're used or not, and there categorically will not be a change in performance from using one over another. – Spudley Aug 25 '16 at 18:34
  • "I've been working on a site that passes one information through $_REQUEST." + " whenever i try using $_GET or $_POST it returns empty" + "because the recent changes made it so the $_GET = $_POST" + `" AND projetos_main.proj_id in (".implode(",", $_POST['proj_id']) .")"` oh boy... I would suggest to start from scratch instead because it looks like your question is the least of your worries right now. – PeeHaa Aug 25 '16 at 19:12

0 Answers0