Reputation: 4778
I'm currently busy with PHP and thought of sending a POST
request to another page without a form to do so. But how do you do this? I googled a bit and saw that cURL was used: is this the best way to go or can you do it (easy) without it?
I was thinking of making a small page where suggestions can be placed and you could decline / accept them. The suggestions are loaded from a (MySQL) database and presented along with an accept and decline button. If accept is clicked i would like to send the parameters to a page that accepts POST
as in this way:
if(isset($_POST['name'] && isset($_POST['text']))
{
// ...
}
I do know this can be done with $_GET
, but i'd like to do it by $_POST
for a change.
Upvotes: 1
Views: 4815
Reputation: 2459
There are two acceptable methods:
Sessions - Instead of using $_POST
, use $_SESSION
Reference: Manual
AJAX - You can send POST requests without a form.
Reference: AJAX tutorial / jQuery AJAX
Upvotes: 0
Reputation: 735
You can send Posts easily via Javascript (Ajax), see jQuery Ajax for examples. Or in PHP just use CURL, it is very easy to use.
If you need a curl-free alternative, use fopen like http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/
see also http://api.jquery.com/category/ajax/
Upvotes: 0