0

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 until 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 :)!

4
  • So, wait, what's that supposed to look like for the user? The user goes to another page to complete some actions but still your site should redirect him…? Can you describe that setup in more detail? Commented Jul 31, 2011 at 22:30
  • Alright, a full description: User enters via homepage -> User is redirected to country specific page -> User clicks on a download link -> Modular JS box popups up, requesting that he/she complete an offer in order to access said link, and has a list of offer links -> Each offer link takes the parameter of "subid" which can hold any value, in this case the users IP address is used as the value -> User clicks on offer which is opened in a new page in order for he/she to complete -> Commented Jul 31, 2011 at 22:37
  • Once completed the users IP address (the value of "subid") is posted back to another PHP script which gets the users IP address and inserts it into a whitelist database -> Module box on other page displays thank you message, redirects through to download page Commented Jul 31, 2011 at 22:37
  • How modern are the browsers that are accessing your pages? It seems like a combination of WebSockets - dev.w3.org/html5/websockets - and using a background processing system like Gearman - gearman.org - would help you accomplish this task. (Regardless of whether or not use can use WebSockets, I would highly recommend incorporating Gearman into your solution.) Commented Jul 31, 2011 at 23:52

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.