-1

I've recently migrated servers and found that all $_POST requests on my website are no longer working. The requests always successfully redirect to the 'post' page, but no data is sent and print_r($_POST) always turns up an empty string. I believe this issue has something to do with PHP's settings because the problem occurs over multiple pages which were working fine on the previous server (GET requests seem to still be working fine).

I created a test.php file in my home directory with a very simple POST form to try to rule out any variables.

<?php print_r($_POST); ?>

<form action="test.php" method="POST">
    Name: <input type="text" name="name"><br>
    <input type="submit">
</form>

the page always prints only an empty the array Array ( )

Any help would be greatly appreciated, I'm sure its something simple but google doesn't seem to have the answer :(

Akshay Parate
  • 185
  • 1
  • 10
Brandon
  • 79
  • 7
  • 2
    I've tested the script works fine. – Wils Apr 24 '18 at 03:20
  • 1
    Assuming your code is on `test.php`, and you're actually entering something in the field and then checking the array, your script does indeed work fine. – Obsidian Age Apr 24 '18 at 03:20
  • Possible duplicate of [PHP POST not working](https://stackoverflow.com/questions/9914979/php-post-not-working) – Obsidian Age Apr 24 '18 at 03:21
  • It know the above code should work but for some reason it doesn't. It just returns an empty array every time, no matter the input. I'm thinking the issue must be with php/server settings but Im not sure. nothing is showing up in the error logs either :( – Brandon Apr 24 '18 at 03:24
  • _"The requests always successfully redirect to the 'post' page"_ <- what does this mean? There should be no _redirection_. What do you see in your browser's _Network_ console? Do you see a POST request to `test.php`? If so, what data is sent in the request payload? – Phil Apr 24 '18 at 03:43
  • *The requests always successfully redirect to the 'post' page* - Please clarify that statement. If you're redirecting, the browser will perform a GET request to the URL you're redirecting to. – Mike Apr 24 '18 at 03:44
  • you should write this code in your test.php write anything in your text and after that click on submit then you will definatlly see array on test.php – Mohini Apr 24 '18 at 04:08

1 Answers1

0

I've realized the issue was in my .htaccess file. My POSTS were being stripped of their extensions and losing all the post data.

this topic php $_POST array empty upon form submission was the most help

Brandon
  • 79
  • 7
  • This does not provide an answer to your question. If you have solved the issue, you should **detail** it here – Phil Apr 24 '18 at 04:06