3

So I have a very basic form that is sending data to a new page but nothing is coming over. I was messing with the PHP.ini file at one point which I suspected to be the issue so I grabbed a copy of default values online but it still isn't working. I'm running PHP version 5.6.15 using XAMPP. I'm wondering if anyone has any ideas as to what might be the issue. For clarity, here's the files:

index.php:

<!DOCTYPE html>
<html>
<body>

<form action="stuff.php" method="POST">
    Type:
    <input type="text" name="things" id="things" />
    <button type="submit" name="submit">Submit</button>
</form>

</body>
</html>

stuff.php:

<?php
var_dump($_POST);
?>

All that shows up is:

array(0) { }

Request

Content-Type: application/x-www-form-urlencoded Content-Length: 20 things=asdsa&submit=

timiTao
  • 1,417
  • 3
  • 20
  • 34
Desquid
  • 131
  • 2
  • 12
  • 1
    Does the request show `things` as transferring as form data in the network tab of the developer console? – chris85 Mar 11 '16 at 16:47
  • 1
    The only ini setting that I can think of is `enable_post_data_reading`. – AbraCadaver Mar 11 '16 at 16:48
  • @chris85 yeah. The request body is this: Content-Type: application/x-www-form-urlencoded Content-Length: 20 things=asdsa&submit= – Desquid Mar 11 '16 at 16:49
  • I am getting array(2) { ["things"]=> string(4) "test" ["submit"]=> string(0) "" } after trying ! Strange i have seen many here who suffers from this problem! http://stackoverflow.com/q/35837572/2667307 – Shashank Shah Mar 11 '16 at 16:51
  • @Desquid Is it possible that the request to `stuff.php` is being redirected along the way? POST arguments will not be redirected. – Jim Mar 11 '16 at 16:52
  • Try `readfile('php://input');`. – AbraCadaver Mar 11 '16 at 16:52
  • @AbraCadaver That was indeed turned off for some reason but it still didn't fix the problem :/ – Desquid Mar 11 '16 at 16:52
  • try actually making a php array in your php file that you came dump everything into. – LatentDenis Mar 11 '16 at 16:53
  • @AbraCadaver ok so yes it is in the readfile('php://input'); raw data so its just not going into the post variable for some reason – Desquid Mar 11 '16 at 16:55
  • The only other ini setting is `post_max_size` so you need to restart webserver and check `phpinfo();` and make sure directives are set correctly. – AbraCadaver Mar 11 '16 at 16:58
  • @AbraCadaver I have that set to 8M – Desquid Mar 11 '16 at 17:17
  • Using a tool like Fiddler, can you verify that the request isn't being redirected, and that the final request to the `stuff.php` file is actually using the `POST` verb? http://www.telerik.com/fiddler – haliphax Mar 11 '16 at 17:21
  • @haliphax yeah I had the same response using fiddler. It also works fine on a live server: http://otcwebdev.net/test/ – Desquid Mar 11 '16 at 17:25
  • What do you mean by "the same response"? That's not quite what I was asking. – haliphax Mar 11 '16 at 17:34

0 Answers0