0

I created a little website from scratch with Mysql database, PHP Sessions etc... on my local WAMP with PHP 5.4.

When uploading the website files to my online host - which is running PHP 5.6 - I have issues with all the GET variables, it seems to not be functionnal.

On my local computer :

// Requested URL : index.php?title=Hello
<?php

echo $_GET["title"]; // works

?>

On the server :

// Requested URL : index.php?title=Hello
<?php

echo $_GET["title"]; // empty. 

?>

Crazy ! I do not understand what happens... I read the "Migrating from PHP 5.4.x to PHP 5.6.x" and the "Migrating from PHP 5.5.x to PHP 5.6.x" but I don't manage to find what is not working.

Do you have any idea ?

EDIT 01/13 : I created a very simple form page :

<?php
echo $_POST["texttest"]."<hr />";
?>

<form action="?" method="POST">
<input type="text" name="texttest" class="texttest" id="texttest" />
<input type="submit" value="test">
</form>

.. The POST var is never displayed. When I look in the Chrome console after submitting the form, I have a message :

Provisional headers are shown

Paolito75
  • 558
  • 1
  • 11
  • 33

2 Answers2

2

setup a test script with phpinfo to see what your ini variables are on the host.

<?php
phpinfo();
?>

http://php.net/manual/en/ini.core.php#ini.variables-order if variables-order is set a certain way - $_GET might not be available...

Mine is set to:

; This directive determines which super global arrays are registered when PHP
; starts up. G,P,C,E & S are abbreviations for the following respective super
; globals: GET, POST, COOKIE, ENV and SERVER. There is a performance penalty
; paid for the registration of these arrays and because ENV is not as commonly
; used as the others, ENV is not recommended on productions servers. You
; can still get access to the environment variables through getenv() should you
; need to.
; Default Value: "EGPCS"
; Development Value: "GPCS"
; Production Value: "GPCS";
; http://php.net/variables-order
variables_order = "GPCS"

If you have access to your php.ini - you can simply change it.

EDIT: OK - confirmed that variables_order = "GPCS".
if the source test code is edited to this - what is the result?

<?php 
echo 'This is my page'; // should always print- just to make sure you are on the correct page 
echo '$_REQUEST:'.print_r($_REQUEST,true); 
echo '$_GET: '.print_r($_GET,true); 
echo '$_POST: '.print_r($_POST,true); 
echo $_GET["title"]; // empty. 
?>
Anthony Gray
  • 344
  • 4
  • 7
  • 1
    Hi Anthony, I have the same conf : GPCS, see screenshot : http://img11.hostingpics.net/pics/702676extract.png – Paolito75 Jan 12 '17 at 15:01
  • @Paolito75 - I edited the answer so it was a bit clearer (multiline code doesn't play well in comments...) - let me know if that has helped point to the issue. :-) – Anthony Gray Jan 12 '17 at 19:22
  • 1
    Your code works... My URL parameter is shown in the REQUEST array and the GET array. But i still have the problem in other cases .. I have edited my original post with a very simple test. – Paolito75 Jan 13 '17 at 12:32
  • did some searching about your latest error - found this (http://stackoverflow.com/questions/21177387/caution-provisional-headers-are-shown-in-chrome-debugger) Do you have AdBlock or other content filter add-ons in your chrome install? Possibly try your request in another browser. Maybe your issue is your browser add-on is whitelisting //localhost links, but not your webhost - potentially explaining why it worked on your local test install but not at the web server... Using the `chrome://net-internals` url they discuss is VERY enlightening. Didn't know it existed... :-) – Anthony Gray Jan 13 '17 at 12:58
  • Your latest test code works 100% in my 5.6.29 environment here - with no errors in Chrome... – Anthony Gray Jan 13 '17 at 13:15
  • 1
    Humm yeah i searched for this message and i have my Adblock disable. Ok then I'm gonna ask for help to the sysadmin of my host, i believe that he may had to change something in the Apache conf in the last few days. I'll come back and share the solution if I find one. Thanks for your help man ;) – Paolito75 Jan 13 '17 at 13:21
  • that's why we're here. :-) – Anthony Gray Jan 13 '17 at 13:23
0

; Whether PHP will read the POST data. ; This option is enabled by default. ; Most likely, you won't want to disable this option globally. It causes $_POST ; and $_FILES to always be empty; the only way you will be able to read the ; POST data will be through the php://input stream wrapper. This can be useful ; to proxy requests or to process the POST data in a memory efficient fashion. ; http://php.net/enable-post-data-reading enable_post_data_reading = Off

remove ; from first line ;enable_post_data_reading = Off

xpredo
  • 1,282
  • 17
  • 27