I have a custom CMS i\'ve built that works perfectly on my dev box (Ubuntu/PHP5+/MySQL5+).
I just moved it up to the production box for my client and now all form su
Not the most convenient solution perhaps, but I figured it out that if I set the form action
attribute to the root domain, index.php can be accessed and gets the posted variables. However if I set a rewritten URL as action, it does not work.
In my case it was because I was using jQuery to disable all inputs on the page just before using jQuery to submit the form. So I changed my "disable every input even the 'hidden' types":
$(":input").attr("disabled","disabled");
to "disable only the 'button' type inputs":
$('input[type=button]').attr('disabled',true);
This was so the user couldn't accidentally hit the 'go' button twice and hose up our DB! It seems that if you put the 'disabled' attribute on a 'hidden' type form input their values won't be sent over if the form is submitted!
I know this is old, but wanted to share my solution.
In my case the issue was in my .htaccess as I added variables to raise my PHP's max upload limit. My code was like this:
php_value post_max_size 50MB
php_value upload_max_filesize 50MB
Later I notice that the values should like xxM not xxMB and when I changed it to:
php_value post_max_size 50M
php_value upload_max_filesize 50M
now my $_POST returned the data as normal before. Hope this helps someone in the future.
For me, .htaccess was redirecting when mod_rewrite wasn't installed. Install mod_rewite and all is fine.
Specifically:
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</Ifmodule>
was executing.
In my case (php page on OVH mutualisé server) enctype="text/plain"
does not work ($_POST
and corresponding $_REQUEST
is empty), the other examples below work.
`
<form action="?" method="post">
<!-- in this case, my google chrome 45.0.2454.101 uses -->
<!-- Content-Type:application/x-www-form-urlencoded -->
<input name="say" value="Hi">
<button>Send my greetings</button>
</form>
<form action="?" method="post" enctype="application/x-www-form-urlencoded">
<input name="say" value="Hi">
<button>Send my application/x-www-form-urlencoded greetings</button>
</form>
<form action="?" method="post" enctype="multipart/form-data">
<input name="say" value="Hi">
<button>Send my multipart/form-data greetings</button>
</form>
<form action="?" method="post" enctype="text/plain"><!-- not working -->
<input name="say" value="Hi">
<button>Send my text/plain greetings</button>
</form>
`
More here: method="post" enctype="text/plain" are not compatible?
If you are posting to a index.php file in a directory for example /api/index.php make sure in your form you specify the full directory to the file e.g
This
<form method="post" action="/api/index.php">
</form>
OR
<form method="post" action="/api/">
</form>
works.
But this fails
<form method="post" action="/api">
</form>