Re: User interface for process that takess a long time...
From: JGH (johnheim_at_nospam.tds.net)
Date: 05/07/04
- Next message: MuffinMan: "Re: add up an integer with the result from substr()"
- Previous message: JGH: "Re: OT: Comparison of Java, Perl, PHP, C++, C#, VB in PECI survey"
- In reply to: Chris Hope: "Re: User interface for process that takess a long time..."
- Next in thread: Chris Hope: "Re: User interface for process that takess a long time..."
- Reply: Chris Hope: "Re: User interface for process that takess a long time..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 7 May 2004 19:38:55 +0000 (UTC)
Chris Hope <chris@electrictoolbox.com> wrote in
> I did this once to do something along the lines of what you are
> wanting to do. It worked for me but I can't guarantee it will work for
> you...
>
> set_time_limit(0);
> ignore_user_abort(1);
> register_shutdown_function("foo");
> header("location: bar.php");
> flush();
> exit();
>
> Then there was a function called "foo" (well it wasn't really called
> that but is in this example) which does all the work. The only issue
> then is how to get the progress page to work out if the work is done
> yet.
>
> Ten seconds isn't really a very long time to wait for something to
[...]
Well, the process might take a lot longer than that but I thought I'd check
it's status (via a flag) every 10 seconds or so. That would make the user
think something is happening.
I used a lot of your code but instead of the shutdown function and a call
to header(), I put a META refresh tag in the header and called the Oracle
stored procedure at the end of the script. So 2 seconds after the script
completes, the page is redirected to another page that shows the results.
The main problem with my approach is that it is subject to all the failings
of the flush() function -- which can't *force* a server (much less the
browser) to flush output. But, well, close enough for gub'ment work. It
works on the servers & browsers we're using today. The worst that can
happen is that the user doesn't get the "Please wait" message. He might
think his browser is hung but by the time he looks up my phone number it
will have finished.
<HTML>
<HEAD>
<META http-equiv=Refresh CONTENT="2; URL=billing.php">
</HEAD>
<BODY>
Please wait...
<?php
flush();
set_time_limit(0);
ignore_user_abort(1);
$stmt = OCIParse ($dbh, "BEGIN DOSOMETHING(); END;");
OCIExecute ($stmt, OCI_COMMIT_ON_SUCCESS);
?>
Finished! This page will refresh in 2 seconds!
</BODY>
</HTML>
- Next message: MuffinMan: "Re: add up an integer with the result from substr()"
- Previous message: JGH: "Re: OT: Comparison of Java, Perl, PHP, C++, C#, VB in PECI survey"
- In reply to: Chris Hope: "Re: User interface for process that takess a long time..."
- Next in thread: Chris Hope: "Re: User interface for process that takess a long time..."
- Reply: Chris Hope: "Re: User interface for process that takess a long time..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|