# Poll+php+txtfile

**URL:** <https://forum.kirupa.com/t/poll-php-txtfile/181994>\
**Category:** Uncategorized\
**Created:** [March 14, 2006, 7:48pm UTC](https://forum.kirupa.com/t/poll-php-txtfile/181994 "2006-03-14T19:48:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zero\_one1](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/zero_one1/32/948_2.png) [@zero\_one1](https://forum.kirupa.com/u/zero_one1)\
**Post date:** [March 14, 2006, 7:48pm UTC](https://forum.kirupa.com/t/poll-php-txtfile/181994/1 "2006-03-14T19:48:16Z")

</div>

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](http://yfellowship.org/ez_poll/belly.txt)  
working poll (swf on same server as php): [http://yfellowship.org/ez\_poll/](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/](http://www.matthewzammit.com/ez_poll/)

flash code frame 1 (before vote button is pressed):

```auto
//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)

```auto
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
<?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);
  
  ?>

```
