PHP sessions/ page refresh???

Discussion in 'PHP' started by ktsirig, May 31, 2006.

  1. #1
    Hello!
    I am having a problem that I think is solved by using sessions and page refresh.
    I have a page where the user enters data. The data are used as input for an external program that runs in the shell, irrelevant to PHP. When the program ends, all results are stored in a text file, which I open with PHP and parse the results so that the user sees them on screen.

    So I have :

    form.php => which contains the form
    [....] => external program that runs in the background and creates temporary text file with the results
    process.php => opens text file and prints the results

    What I would like to do is something I have seen in many websites. I want to have an 'intermediate' page that will say for example "Please wait, we are processing your request".... This page will automatically refresh when the external program ends and then it will redirect to process.php file to show the results.
    I think it is better to have such a page instead of 'stucking' to the initial page [form.php] during the processing time and then display the results.
    Note that the external program can end in 1 minute, but it can last for 4 or 5 minutes if the user has submitted lots of data.
    Any ideas on how to do this?
     
    ktsirig, May 31, 2006 IP
  2. Slapyo

    Slapyo Well-Known Member

    Messages:
    266
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    You could have a page that would refresh every 15 seconds, or however long you want. Each time the page loads it looks to see if the file is complete ... looking for a particular last line in the file. If it finds that line, rather that loading that page up again, it sends the user to process.php which will show the results.

    All you need is for the external program to output a line to the very end of the file when it is done that lets you know it is complete.
     
    Slapyo, May 31, 2006 IP
  3. Veselin Stoilov

    Veselin Stoilov Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you may also use
    http://www.php.net/manual/en/function.filectime.php
    to see when the file was changed.
     
    Veselin Stoilov, Jun 6, 2006 IP