Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 31st, 2006, 2:55 AM   #1
ktsirig
Programmer
 
Join Date: Oct 2005
Posts: 54
Rep Power: 3 ktsirig is on a distinguished road
PHP sessions/ page refresh???

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 is offline   Reply With Quote
Old Jun 1st, 2006, 3:13 PM   #2
Mocker
Hobbyist Programmer
 
Mocker's Avatar
 
Join Date: Oct 2005
Location: Indiana
Posts: 202
Rep Power: 0 Mocker is an unknown quantity at this point
Send a message via AIM to Mocker
You could just print the "please wait" message, then call the system and it will run it, then continue with the rest of the program where you print the code to redirect the page. Look up the difference between system() and exec() to see how it handles executing external programs.

If you are waiting that long though you may need to do something else. I know there are some built in timeouts for both php and apache (or whatever webserver) that can terminate your script if it takes too long.

I'm thinkin you could have an intermediate page that refreshes itself every few seconds and checks if the external program is done running. If it is still running, it will still print the wait message, otherwise go to the finished page.
__________________
#programmingforums relay - http://thegupstudio.com/cgi-bin/pforelay.cgi
freelance scripts - http://ryanguthrie.com/index.html
Mocker is offline   Reply With Quote
Old Jun 1st, 2006, 4:16 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The relationship between the client and the server is not interactive. If you should do as mocker suggests (with some sort of timed redirect) you are actually subverting the client's prerogatives. If you're app is important to him, he may stand for it. If I caught someone doing that with my machine I would immediately put their address in my "shitcan this effer" list. Just sayin'.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC