Take the 2-minute tour ×

There are numerous examples of being able to POST a variable from one PHP script to another.

I want the first script to POST to the second script, but to keep the first script still running. The files are crawler.php and links.php. How do I do this?

share|improve this question
This is the first time I've seen a reporter from the Daily Mail write a question on Stack Overflow. –  Hammerite Oct 25 '11 at 6:11
is cURL the solution? –  Explosion Pills Oct 25 '11 at 6:14
Sorry! I wa slightly annoyed that last time I asked a question, 20 people commented saying that it was too hard, or that you couldn't (you can), or that they needed more information than was humanly possible to include. –  Thomas Foster Oct 25 '11 at 6:16
Can you desribe exatly what you are trying to do and specifically what you mean by "post" (ie. a second http request, passing through a socket, etc..) –  prodigitalson Oct 25 '11 at 6:17
@tandu I've seen a solution in a Google search that did that, but it made no sense to me at all. –  Thomas Foster Oct 25 '11 at 6:17
show 9 more comments

1 Answer

Use cURL

// crawler.php
$url = 'localhost/links.php'; // Change me to what ever
$fields = array('foo' => 'bar');

//url-ify the data for the POST
$fields_string = '';

//open connection
$ch = curl_init();


//execute post
$result = curl_exec($ch);

//close connection

See http://davidwalsh.name/execute-http-post-php-curl


I just realised you wanted an async call.

In that case, you can look into pcntl fork http://php.net/manual/en/book.pcntl.php

Or How do I make an asynchronous GET request in PHP?

share|improve this answer
Does that require for something to be sent back to the original script? (the edit) I just didn't want the first script to stop running after I had sent the request, which is what the examples I saw did. The cURL will work I guess :) –  Thomas Foster Oct 25 '11 at 7:33
add comment

Your Answer


