Jump to content

PHP sessions/ page refresh???


ktsirig

Recommended Posts

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?
Link to comment
Share on other sites

Well, first of all, how does process.php know that the text file is ready to be opened (read: finished)? or do you have it set to open the file after a certain amount of time?

You might be able to set up a middle-man page that checks for.. I suppose the 'existance' of the certain text file, and then wait's atleast 10 seconds if it's not found, then looks again (while displaying 'Loading' or whatever you may want). The external program, hopefully written by you, or having the possibility to be modified should be set to hold the data in it's buffer then to write all the data to the textfile at once if you happened to use the check for the existance of the file method I just specified so it doesn't open the file mid-write.

I'm not that experienced with external program use and PHP, so I might just be totally wrong on this. But I'm sure there is someone else here who could help.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.