#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    Hi Everyone,
    I want to do two things on the same page in PHP. The first is quick and I want to output the result to the client (this works). The second takes a long time and depends on the result of the first. Basically what I would like to do is:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><html>
    <body>
    <?
    Do fast job, output to client
    ?>
    </body>
    </html>
    <?
    Do slow job, have already closed connection to client so client doesn't care that it's slow.
    ?>[/code]

    However, I don't know how to close the client connection. The client's browser sits there waiting for the script to end.

    One other solution I think would be to use "system()" to start a CGI script. Two problems, I don't know how to compile and run PHP as a CGI script, and I don't think I have a PHP binary executable on my host.

    Any help appreciated.
    Thanks,
    Garth
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    Regardless what your logic is, you can try to execute/include a Perl script. for the bottom part.
  4. #3
  5. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    2
    Rep Power
    0
    Yup, I've read the section on connection handling. Unfornately it only deals with what happens if the client closes the connection during execution of the script. It doesn't describe how to close the connection and continue script execution (or really anything to do with server side control of the connection).
  8. #5
  9. No Profile Picture
    Gödelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    Oh, that... easy; you have a couple of ways:

    1. Send a URL header to redirect the browser to another page, such as:
    <?
    header ("Location: your_logout_page.php?a_variable_if_you_want_one=$foo");
    ?>
    (normally one would call the 'exit;' command afterward to end any further execution of the present script, but in your case, you would just want to call the header, and redirect the browser while the script finishes execution.)

    2. If you want the page to close completely just use the javascript function window.close(). You could use it in <form onsubmit="window.close()"> or in your submit button with the 'onclick' event handler. The user will be prompted for authorization to close the page, though.

    Yes, you have no real server-side control of the client connection, because there is no true 'connection' -- such as a socket -- with HTTP. But one (or both) of the above will be the next best thing.

Similar Threads

  1. Custom error message for MySQL connection
    By dbr1066 in forum PHP Development
    Replies: 6
    Last Post: February 12th, 2004, 11:25 AM
  2. time in - time out
    By newbiex in forum PHP Development
    Replies: 2
    Last Post: February 9th, 2004, 02:04 AM
  3. Replies: 0
    Last Post: January 27th, 2004, 09:54 AM

IMN logo majestic logo threadwatch logo seochat tools logo