开发者

Running a php script in the background

I have a script that will take a long time to process, let me call it form1.php

Now i post from form1.php to form2.php.

On form1.php I ask the user to enter his email content to send the employs of all departments.

Now what i need is that when i post from form1.php to form2.php, the browser should show a message that says processing.. mail will be sent to all employ email address and the user should be redirected to form2.php with out waiting for the script to send email to all employs开发者_如何学C which may take some time. I want this script to run in background and user should continue other work on site.

In the background the script must do what its supposed to do

Please give me any idea how to accomplish this?

Thanks


AJAX will fit your needs. AJAX perform an HTTP call on the background with Javascript. Still with Javascript you can create a loader or show a gif loader in the middle of the page. I suggest you not to use frames because not still supported by all browser.

Quoting W3C (WWW Consortium):

AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

  • Ajax on w3c


For such purpose you can make use of iframe's.


have you tried cURL? some example from http://php.net/curl-init

<?php
// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜