Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1499 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

PHP sessions/ page refresh???

Thread title: PHP sessions/ page refresh???
Closed Thread    
    Thread tools Search this thread Display Modes  
05-31-2006, 07:39 AM
#1
ktsirig is offline ktsirig
Status: Junior Member
Join date: Oct 2005
Location:
Expertise:
Software:
 
Posts: 46
iTrader: 0 / 0%
 

ktsirig is on a distinguished road

  Old  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?

05-31-2006, 07:51 AM
#2
sysblnk is offline sysblnk
Status: I love this place
Join date: Mar 2005
Location:
Expertise:
Software:
 
Posts: 640
iTrader: 0 / 0%
 

sysblnk is on a distinguished road

  Old

You should look into AJAX, basically you have your page and once the form submits you can change your content to say please wait while your we process etc..

When it is ready the PHP script will tell your Javascript it's ready and there you can put a refresh to a new page or whatever you want to do.

This is the most unobtrusive and probably best method for your server. Otherwise you can use a constant loop to see if the script is done which would put a load on your server.

05-31-2006, 11:31 AM
#3
jono1 is offline jono1
jono1's Avatar
Status: Non-conformist
Join date: Jul 2005
Location: Canberra, Australia.
Expertise:
Software:
 
Posts: 1,172
iTrader: 0 / 0%
 

jono1 is on a distinguished road

  Old

You don't need AJAX, and you don't really need a middle step. Form processing is generally damn near instant and putting up a "please wait" message just makes the user wait unnecesarily.
All that's really necessary is:
form.php - take the input
process.php - processes the results and then prints them.
why the extra step?

05-31-2006, 11:36 AM
#4
sysblnk is offline sysblnk
Status: I love this place
Join date: Mar 2005
Location:
Expertise:
Software:
 
Posts: 640
iTrader: 0 / 0%
 

sysblnk is on a distinguished road

  Old

Reading his post the process sometimes takes up to a minute..that in my opinion would be a pretty good reason to take an extra step, it shows the user that something is going on in the background and their browser didnt just freeze, it's also what the cool kids do.

As I said earlier there is no need for AJAX but it would definately be worth doing, the browser will never timeout with long processes which this seems to be is a big factor.

Closed Thread    


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

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed