Continuous MySQL Database Querying in PHP?
I'm looking for the easiest and most sensible way to allow this scenario to occur;
User loads page --> While page is loaded it continuously queries a database unti开发者_开发问答l it finds a certain value is set (the users IP address) --> Once that value is set it will redirect the page.
The reason why I can't simply take the users IP on the page, insert it into the database and then redirect is because the IP address is used for a method of validation, and is passed through as a parameter to a seperate website (that I have no control over), then once the user has completed a set of actions on that website it is passed back and added into my database.
If anyone could point me in the write direction, of which PHP functions I could use and such, I would greatly appreciate it :)!
The best way to keep querying on the original page is probably via AJAX. Send an AJAX request to a script on your server every 20 seconds or so to check whether the database has been updated with the data you're looking for. To make this more realtime, long-polling/Comet is a technique you may want to look into as well.
A very low-tech solution would be a simple page that keeps refreshing itself, checking the database on each load.
Using the IP as the unique identifier is not very granular though. That may give a large range of people blanket access if only one person filled out an offer. Unless that's no problem for you, it'd be better to create a long random string, save it in the session, send it along as the subid
and wait for it to come back. That way you can identify a user uniquely. You could even identify specific actions a user took uniquely.
Hope that gets you going.
精彩评论