I’m doing this poll (just yes/no answer) to be hosted on a server which doesn’t have php. results are then saved in a txt file.
so i thought i would have the swf file on the server and then have the php file and text file holding the variables on another server which has php.
I uploaded the php and txt file on the server and played the swf locally and it works fine, and variables are read and saved properly in txt file. but when i run the swf file from the server it doesn’t find the vars from the other server.
(hope i was clear)
txt file: http://yfellowship.org/ez_poll/belly.txt
working poll (swf on same server as php): http://yfellowship.org/ez_poll/
where i want it but it’s not working (loads php and txt file from url abaove): http://www.matthewzammit.com/ez_poll/
flash code frame 1 (before vote button is pressed):
//create a nre data object to load data into it.
myData = new LoadVars();
myData.load("http://yfellowship.org/ez_poll/belly.txt");
//create new data holding object
yourVote = "";
//choose radioButton
bellyListener = new Object();
bellyListener.click = function(evt) {
yourVote = evt.target.selection.data;
};
belly.addEventListener("click", bellyListener);
//confirm choice
vote.onRelease = function() {
if (yourVote != "") {
gotoAndStop("submit");
if (yourVote == "YES") {
myData.yesVotes++;
}
if (yourVote == "NO") {
myData.noVotes++;
}
myData.totalVotes++;
myData.sendAndLoad("http://yfellowship.org/ez_poll/save.php", myData, "POST");
}
};
stop();
flash code frame 2 (when vote button is pressed)
yesVar = myData.yesVotes;
noVar = myData.noVotes;
totalVar = myData.totalVotes;
percYes = math.round((yesVar/totalVar)*100);
percNo = math.round((noVar/totalVar)*100);
fYesVar = yesVar+"/"+totalVar+" ( "+percYes+"% )";
fNoVar = noVar+"/"+totalVar+" ( "+percNo+"% )";
stop();
php code
<?php
$yesVotes = $_POST["yesVotes"];
$noVotes = $_POST["noVotes"];
$totalVotes = $_POST["totalVotes"];
$toSave ="yesVotes=$yesVotes&noVotes=$noVotes&totalVotes=$totalVotes";
$fd = fopen("belly.txt", "w"); //a+
fwrite($fd, $toSave);
fclose($fd);
?>