File 1
Poll.php
[php]<?php
?>
Do you prefer using contractor or do it your self?
contractor:myself:
File 2
[php]<?php
setcookie(“poll”,“1”,time()+86400*30);
if($_COOKIE[‘poll’] == 1)
{
die (“you’ve already voted in this poll”);
}
ELSE
{
echo ‘Thank you for your vote’;
}
$vote = $_REQUEST[‘vote’];
//get content of textfile
$filename = “poll_result.txt”;
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0)
{
$yes += 1;
}
if ($vote == 1)
{
$no += 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,“w”);
fputs($fp,$insertvote);
fclose($fp);
?>
Results: Do you prefer using contractor or do it your self?
contractor: |
|
myself: |
|
Number of votes: | <?php echo ($yes+$no); ?> |
[/php]
File 3
text file.txt = to save results
]Hello, Ill try to be as specific as i can, I am trying to use the code above as i have learned from w3 schools and i am trying to figure out how i can add a text link on my poll to linnk to the results without actualy adding another value to the total amount of votes… Just a link to the results. I am a new programmer and i love trying to learn but as you know examples are very helpfull. Any help is greatly appreciated