Regarding the error, you can check these links (I assume you've already seen this):
How do I resolve a HTTP 414 “Request URI too long” error?
Request-URI Too Large
And for your question: I want to know how to use POST request in PHP.
- Create a form.
(I assume that the textbox from this form will get the long data that you want to POST).
<form method="POST" action="http://localhost/data.php">
<input type="text" name="input_text" />
<button type="submit">Submit</button>
</form>
Receive the data from the from input using the defined method on your form. In this case the method is POST
and the url/file that will receive the submitted data is http://localhost/data.php
.
if (isset($_POST['input_text'])) {
// Where input_text is the name of your textbox.
$text = $_POST['input_text'];
echo $text;
}
ERROR : Request-URI Too Long.
$_REQUEST, as you say, handles $_POST
and $_GET
methods is correct.
Regarding your question, even though you use $_REQUEST
to get the data, in the background it use the $_GET
method to catch the query string you pass with the url.
$_GET
method has limit on size and this is the main reason why you encounter that error. Whereas $_POST
method don't have limit: Is there a maximum size for content of an HTTP POST?.
Conclusion: Better not use $_REQUEST
, use $_GET
or $_POST
specifically :D