many refreshes

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

many refreshes

Post by newmember »

what happens when user refreshes page so fast that there is not enough time (between refreshes) for php script to run to the end?
each time server will launch new instance of the same script(php page)?
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

I think it may slow the server down a little as so many requests are sent. Not sure on that one...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

a new instance of the page will launch, while the others are still finishing.. but they will finish. This is the same problem with high-volume sites running non-cached code. Running on a higher-end server can aleviate this a lot.. running on a load balanced cluster, really helps.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

on the same subject...
what happens when user opens the same page a few times?
in this case also there will be separate script instance launch for each open page on user's side?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

lets say that this page contains form... so each instance of script will get this form and work on it...
but it is a real problem because the intention was to recieve only one form...
how do you treat this situation?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it only gets 1 form, for each instance sent back. the processor gets a submission, and spits whatever it needs to back.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

i didn't undestand you... maybe i was not clear in my question....i'll try again

i open at the same time in my browser the same page 5 times. each page has a form. i fill all 5 forms and hit submit for each of them. now, you say that for each submission i make, server will launch the same script 5 times...each script proccess form's data and does something with it...
so here is the problem because i don't want five instances to work on the same form...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you want the form to only work once? ever? then it needs to be built to stop responding after a single access, or stop responding once each passes through it successfully.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

ok thanks
(i hoped php has some mechanism for dealing with such situations...)
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

newmember wrote:ok thanks
(i hoped php has some mechanism for dealing with such situations...)
You have to build one.. ;)
mikeb
Forum Commoner
Posts: 60
Joined: Tue Jul 08, 2003 4:37 pm
Location: Dublin, Ireland

Post by mikeb »

Multiple form posts can be a pain. If the data is being dumped into a database table, then try an approach like this:

Code: Select all

//include an email field on form
- user posts form

//Your script on the server
- Query database for existence of user's email
- Is user's email already in database?
NO{
- Stick user email into database
- Stick form data into database (or email it or whatever)
}
YES - Ignore user form input 
- end
Same thing could be acheived using session variables and checking for their existence with the same YES/NO responses

The problem with this is that you are not giving the user a chance to correct a form which they posted incorrectly! Many sites simply have a message 'PRESS THE SUBMIT BUTTON ONCE ONLY, FORM MAY TAKE A FEW SECONDS TO POST' lol! sometimes that might be the best thing,

cheers,

Mike
Post Reply