Jump to content

[SOLVED] Using PHP to create a Timer? Or delay certain output to the screen for Xsec,How?


physaux

Recommended Posts

Hey guys i was wondering if anyone knows how to delay output to a screen, or something like that.

 

How i think i would do it-

Access database for time to print

Then print part of the page at that time by some trigger waiting for that time?

 

Like i want to print the following at the very start:

YOUR NAME: bob
YOUR EMAIL: [email protected]
//Wait say 20seconds after he last used my captcha(time from database)
Captcha:[input]
Submit
More data..

 

Maybe i could show a short countdowntimer to "release" time.?

So you see the part i want delayed is in the middle of the instant output. Any suggestions?

I may be wrong, but I'm leading toward no, this is not possible.

 

HTTP is a stateless protocol. It sends complete text files containing all headers/content that the browser needs, and the browser sends complete text requests.

 

You can use javascript to accomplish this, but all the data will be submitted instantly and it'll just be the user's browser delaying it.

 

You could use AJAX to delay it. This would prevent you from sending the data, but you would have to have a way of identifying the original request and sending the appropriate information. Since HTTP is stateless, you need something like sessions to re-identify the same user.

hmm yea i suspected that..

Then i would probably just want to reload the page at a certain delay, or use javascript as you said.

How would i do this with javascript (never used it, a point at good resource would be nice  8))

Is there a way to do it by reloading a page or just an image(which would be my captcha)

 

[EDIT:]

Like, how does youtube show things like "comment posted" when you click, how do the download websites like rapidshare use the timers to let you download? (I assume they just release it server-side to your ip after internal timer)

 

I may be wrong, but I'm leading toward no, this is not possible.

 

HTTP is a stateless protocol. It sends complete text files containing all headers/content that the browser needs, and the browser sends complete text requests.

 

You can use javascript to accomplish this, but all the data will be submitted instantly and it'll just be the user's browser delaying it.

 

You could use AJAX to delay it. This would prevent you from sending the data, but you would have to have a way of identifying the original request and sending the appropriate information. Since HTTP is stateless, you need something like sessions to re-identify the same user.

You can do a refresh with HTML. Read up on it here (just remember, you have to re-identify the user!):

http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm

 

Doing it with javascript involves the setTimeOut function. You can read about it here:

http://www.sean.co.uk/a/webdesign/javascriptdelay.shtm

 

As far as youtube goes, that's done via AJAX (Asynchronous Javascript and XML). AJAX allows Javascript to send an HTTP request to the server (without loading a new browser page or creating a new entry in the browser's history - just remember, it's a regular HTTP request, you still have to identify the user, you also may need to identify that it's an AJAX request and not a regular request depending on how you set your webpage up!), get a response from the server, and then process that response and update the page the user is currently viewing without refreshing it.

 

AJAX is a big beast. It's extremely powerful, extremely useful to learn, and a lot of work to perfect (from my experience, anyway - and no, I have not perfected it, I still consider myself a beginner). W3 School can get you started using AJAX. There are other tutorials on the web too.

 

As for count down timers, this could be done with a variety of javascript and HTML (possibly AJAX). It can also be done with Flash or even Java. I couldn't tell you exactly how they tackle that project.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.