Forum Moderators: coopster

Message Too Old, No Replies

Call an external script

         

andrewsmd

2:42 pm on Nov 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So I have a voting website I am putting up and I have an external php script that runs a check on the votes before it inserts them. This is to try to make sure votes are not from a bot or script or something like that. Basically what I do is store all of the votes into a temporary votes table then run checks on them. I have a column called good which defaults to 'y'. Once there are 500 votes in this table I want to run my validator on it. It set's the value of good to 'b' on any vote that fails my checks. Then, I insert all of the votes with a value of 'y' to a good votes table and any votes with a value of 'b' into a bad votes table. What my question is, how can I execute my inserter.php script on 500 votes but not make the user wait. The psuedo is like this
if(the user clicks the vote button){

if(there are more than 500 votes){

//i want to run my inserter file
//but not make the user wait on it for their
//output i.e. thanks for voting
runMyInserter();

}//if there are more than 500 votes

}//if the user clicks the button

supermanjnk

12:41 pm on Nov 4, 2008 (gmt 0)

10+ Year Member



You could set up a cron job so that it runs every X minutes, days, hours, whichever. That way the script will run without needing a user to trigger it first.

andrewsmd

1:35 pm on Nov 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would be how I would normally do it, but I don't have access to that.

supermanjnk

2:34 am on Nov 5, 2008 (gmt 0)

10+ Year Member



You could possibly use AJAX to run the function without reloading the page, so the user would never even know that it was running. If you did it this way though, I would set a flag somewhere that says it was last run at X time, and that if it hasn't been over Y amount of time since the last run it won't run (this would reduce the risk of the script running multiple times at the same time)