A JavaScript question and a PHP question.


JavaScript question.

I have a web page incorporating JavaScript, but it doesn't work when the user reloads it using the browser back button. The problem is that any variables that I set up the first time it loaded are now lost. Is there any way to prevent this? - load them into an object which is permanent for that browser session perhaps? If not, is there a way to detect if the page has been accessed using a browser back button?

PHP Question.

I want to throttle sending out emails to a mailing list. So I was looking for a function like pause(), wait(), delay(). At least this is the sort of function I was looking for on php.net, to no avail (there are hundreds of functions). Ok, my searching skills probably suck - can anyone tell me what function there is? Also, what's the modulo operator in PHP, is it %?

Thanks, and apologies for my ignorance :(


I thought of cookies, but hoped there was another way.

"Throttle". Well, I could mean I want to grab it by the neck and shake it - which sounds like a good idea. Actually, I just want it to pause after every 100 mails are send. My web hosts prefer that I do this.

I want to write something like this in the mailing loop:

if ($i%100==0) pause(50);

-but in the correct syntax, obviously.


Where mah "any" keys at?
For the Javascript problem, can you set it up so you can store the Javascript variables with PHP? You'd then be able to access them using the $_GET or $_POST globals.

For the PHP problem, you could set the page to send 100 emails, then refresh after so many seconds using HTML. You could keep track of where you sent the emails using the aforementioned variables and send to the next batch upon refresh.

I'm not all that savvy in PHP or Javascript, so I don't know the exact implementation you should take, but I know enough about them that these should work with some clever coding.


I was thinking of refresh as well but this has the inconvenience of not taking into account the time your server will take into sending the mails out. You probably would end up setting a refresh interval larger than the actual PHP processing time to be on the safe side. This would lengthen the overall processing time of all mails. And my guess is you want the mails out quick.

Try the PHP Sleep() function.