askmike
askmike

Reputation: 1970

$_POST is empty on some pages while posting data

I'm building my own website in PHP, somehow my tracking has stopped working since yesterday. I have been debugging the problem for a day now but can't seem to find the solution. I found the problem on my live website but it looks exactly the same on my local XAMPP.

The tracking on my site has 2 parts:

The problem is in my PHP script, which does not appear to recieve POST data. I simulated the tracking script by this HTML form:

<form method='post' action='<?= BASE ?>/track'>
 <input name='test'>
 <input name='submit' type='submit'>
</form>
<form method='post'>
 <input name='test'>
 <input name='submit' type='submit'>
</form>

The first form is pointing to the tracking script and the second to itself. Both the tracking script and this script have this PHP included:

var_dump($_POST); 
echo '<hr>';

When I fill the second form the page gets loaded and I see something like:

array(2) { ["test"]=> string(4) "sfad" ["submit"]=> string(6) "Submit" }

And when I fill the first form in I get this output:

array(0) { }

I can provide more code but the project is getting quite big, what could I have done wrong?

Upvotes: 0

Views: 369

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799580

Try adding a slash at the end of the action so that the web server doesn't redirect the request.

Upvotes: 1

Related Questions