jacobdesch
09-19-2009, 03:40 PM
I'm having a bit of trouble with a Flash/PHP voting system. Basically, it's using a loadVars object to send a simple Number variable to a PHP file that connects with a database and returns.
But for some reason, I can only get the votes to count when I test locally with an absolute path to the PHP file on the server. When I put it live, it will read the PHP file but doesn't seem to be able to send the voting data to it. Anybody have any suggestions? Here's my code:
//----- On load data function -----//
var dataIn:LoadVars = new LoadVars();
var dataOut:LoadVars = new LoadVars();
//gets called when the page loads and returns the total number of votes just fine
dataOut.sendAndLoad("http://www.mydomain.com/poll/vote.php",dataIn,"POST");
dataIn.onLoad = function(ok) {
if (ok) {
var totalVotes:Number = this.totalVotes;
_root.voteFeedback = totalVotes+" TOTAL VOTES";
} else {
_root.voteFeedback = "error";
}
};
//the function that gets called on a button release elsewhere that reads the selection you've voted for.
//for some reason, it send the number of votes when i put it live
function pollVote() {
dataOut.choice = _root.voteSelection;
dataOut.sendAndLoad("http://www.mydomain.com/poll/vote.php",dataIn,"POST");
}
Like I said, everything works fine in local testing, but when I put it live, the votes don't get counted, whether I use an absolute or a relative path to the PHP file on the server. Help!
But for some reason, I can only get the votes to count when I test locally with an absolute path to the PHP file on the server. When I put it live, it will read the PHP file but doesn't seem to be able to send the voting data to it. Anybody have any suggestions? Here's my code:
//----- On load data function -----//
var dataIn:LoadVars = new LoadVars();
var dataOut:LoadVars = new LoadVars();
//gets called when the page loads and returns the total number of votes just fine
dataOut.sendAndLoad("http://www.mydomain.com/poll/vote.php",dataIn,"POST");
dataIn.onLoad = function(ok) {
if (ok) {
var totalVotes:Number = this.totalVotes;
_root.voteFeedback = totalVotes+" TOTAL VOTES";
} else {
_root.voteFeedback = "error";
}
};
//the function that gets called on a button release elsewhere that reads the selection you've voted for.
//for some reason, it send the number of votes when i put it live
function pollVote() {
dataOut.choice = _root.voteSelection;
dataOut.sendAndLoad("http://www.mydomain.com/poll/vote.php",dataIn,"POST");
}
Like I said, everything works fine in local testing, but when I put it live, the votes don't get counted, whether I use an absolute or a relative path to the PHP file on the server. Help!