0

I am trying to get the data in $_POST using code like this:

The main index.php:

<form action="./action.php" method="post">
    <input type="text" name="name" value="ok" />
    <input type="submit" name="submit" value="submit" />
</form>

The action.php inside the same folder of the index.php:

 <?php
 echo $_SERVER['REQUEST_METHOD'];
 echo $_POST['name'];
 echo var_dump($_POST);

Once I launch the local host from phpStorm on index.php. I click the submit button, the page will transform to action.php as planned, and the new page displays: (I deleted the user path below.)

POST
( ! ) Notice: Undefined index: name in /action.php on line 3

action.php:4:
array (size=0)
  empty

In the phpinfo(), I have upload_max_filesize = 10M and post_max_size=20M, and enable_post_data_reading = On.

I have searched multiple forums and end up with posting the question. Thank you for your help in advance.

  • Possible duplicate of [php $\_POST array empty upon form submission](https://stackoverflow.com/questions/1282909/php-post-array-empty-upon-form-submission) – Ole Haugset Jan 23 '18 at 22:58
  • Just tried out your code and it works fine. So the code itself works on my system. – TimBrownlaw Jan 23 '18 at 22:58
  • This is most likely a configuration issue with your PHP setup. As Tim said, the code will work, it's not complex. You'll need to double all POST related variables in your php.ini – Steve Jan 23 '18 at 23:23

0 Answers0