I have a php script that is slow, but must complete in it's entirety. At the end of the script it redirects to a url.

I am thinking of somehow displaying an iframe while the scirpt is loading so visitors don't leave the page. What is the best way of doing this? With the iframe there would be no need to redirect after the completion of the script.

```
    <?php

require_once('config.php');

if(!$_SESSION['init']){
    die;
}

unset($_SESSION['init']);

require_once('facebook.php');

$data = loaddata();
$facebook = new Facebook(array(
  'appId'  => $fbappid,
  'secret' => $appsecret,
  'cookie' => true,
));

$friendsdate = $facebook->api('/me/friends');
if($friendsdate && $friendsdate['data'] && count($friendsdate['data'])){
    $friends = array();
    foreach($friendsdate['data'] as $f){
        $friends[] = $f['id'];
    }

    sleep(3);

    $session = $facebook->getSession();
    $params = array('name' => $data['name'], 
                     'start_time' => $data['start_time'], 
                     'end_time' => $data['end_time'],
                     'description' => $data['description']);
    if($data['source']){
        $params['source'] = '@'.realpath('image/'.$data['source']);
        $facebook->setFileUploadSupport(true);
    }
    $result = $facebook->api('/me/events', 'POST', $params);

    sleep(4);
    $eid = $result['id'];

    $params = array(
        'access_token' => $facebook-> getAccessToken(),
        'eid' =>$eid,
        'api_key' => $fbappid,
        'uids'=> implode(',', $friends),
        'format'=>'json-strings',
        'personal_message'=> $data['personal_message']
    );

    $url = 'https://api.facebook.com/method/events.invite';
    $facebook->setFileUploadSupport(false);
    $result = $facebook->makeRequest($url, $params);
}

header('Location: '.$data['url']);

```