Reputation: 1451
I am stuck for two days, I am working with web services and this web services is make request from iOS
, They are send request with $_POST
method but it is not working.
I tried to print_r($_POST)
but its return blank Array()
and also try with $_REQUEST
but its return blank Array()
only GET
method work proper.
I also make <form>
and try to submit with POST
method and print both $_POST
and $_REQUEST
then both are work proper.
When print $_SERVER['REQUEST_METHOD']
then it return GET
.
Please does anyone know how it happenned?
Upvotes: -5
Views: 212
Reputation: 1451
Here, I am able to find my answer and issue. For mod_rewrite
is change request method. If you have a rewrite rule that affects the action URL, you will not able to read the POST variable.
You have to add this rule to .htaccess
, at the beginning, to avoid to rewrite the url:
RewriteRule ^login.php - [PT]
Upvotes: 0
Reputation: 9143
Firstly, we would need to see your code to be able to help you fully. Below is a little example of how to use forms in combination with PHP and $_POST
.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "<pre>";
var_dump($_POST);
echo "</pre>";
exit;
}
?>
<!-- HTML -->
<form method="POST" action="<?= $_SERVER['PHP_SELF']; ?>">
<input type="text" name="element" />
<button type="submit">Submit form</button>
</form>
Upvotes: -1