Arama butonu
Bu konudaki kullanıcılar: 1 misafir
1
Cevap
396
Tıklama
0
Öne Çıkarma
PHP ANKET
C
11 yıl
Teğmen
Konu Sahibi

Arkadaşlar İyi Günler Dreamweaver'da Anket Yapmam Lazım 3 veya 4 sorulu sonuçları txt dosyasına kaydetmesi lazım. Bir türlü beceremedim SOn çare olarak konu açtım Final notu yerine geçecek Yardımcı olurmusunuz lütfen. Teşekkürler.



A
11 yıl
Yüzbaşı

İndex.php


 

<?php
/*************************************************
* Micro Polling System
*
* Version: 1.0
* Date: 2007-04-05
*
* Usage:
* Add your votings settings to polldata.txt file
* The first line is the question and the other
* linas are the possible answers.
*
****************************************************/

$pollQuestion = '';
$answers = '';

function readData(){
global $pollQuestion,$answers;
// Read configuration
$rawdata = file('polldata.txt');
// Get the question for polling
$pollQuestion = $rawdata[0];

// Get number of answers - The foirs row is the question
$numberOfAnswers = sizeof($rawdata)-1;
$count = 0;
for ($i=1; $i <= $numberOfAnswers; $i++){
$answerData = explode(':',$rawdata[$i]);
// If tha actual row is not empty than add to the answers array
if (strlen(trim($answerData[0]))>0){
$answers[$count]['text'] = $answerData[0];
$answers[$count]['count'] = $answerData[1];
++$count;
}
}
}

function writeData(){
global $pollQuestion,$answers;
$file = fopen('polldata.txt','w');
fwrite($file,$pollQuestion."\r\n",strlen($pollQuestion));
foreach ($answers as $value) {
$row = $value['text'].':'.$value['count']."\r\n";
fwrite($file,$row,strlen($row));
}
fclose($file);
}

readData();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Micro Polling System</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="main">
<?php if (!isset($_POST['submitBtn'])) { ?>
<div class="caption"><?php echo $pollQuestion; ?></div>
<div id="icon"> </div>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="poll">
<table width="300">
<?php
foreach ($answers as $value) {
echo '<tr><td><input type="radio" name="polling" value="'.$value['text'].'"/> '.$value['text'].'</td></tr>';
}
?>
<tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Vote" /></td></tr>
</table>
</form>
<?php
} else {
$count = 0;
foreach ($answers as $value) {
if ($value['text'] == $_POST['polling']) {
$answers[$count]['count'] = ((int)$value['count'])+1;
(int)$totalCount++;
}
++$count;
}

writeData();
?>
<div class="caption">Thanks for your vote!</div>
<div id="icon"> </div>
<div id="result">
<table width="300">
<?php
foreach ($answers as $value) {
echo '<tr><td> '.$value['text'].'</td><td>'.$value['count'].'</td></tr>';
}
?>
</table>
</div>
<?php } ?>
<div id="source">Micro Polling System 1.0</div>
</div>
</body>





polldata.txt


 
What is your favorite color?
red:0
green:0
blue:0
yellow:0
orange:0
black:0
white:0







style/style.css

 

#main {
margin: auto;
border: 1px solid #cccccc;
width: 400px;
background: #F1F3F5;
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
font-size : 12px;
}

form {
margin-left: 80px;
border: 1px solid #cccccc;
width: 300px;
background: #E9ECEF;
font-family: Arial, Helvetica, sans-serif;
font-weight:normal;
font-size : 12px;
padding:5px;
margin-bottom:10px;
}

#result {
margin-left: 80px;
border: 1px solid #cccccc;
width: 300px;
background: #E9ECEF;
font-family: Arial, Helvetica, sans-serif;
font-weight:normal;
font-size : 12px;
padding:5px;
margin-bottom:20px;
}

.text {
border: 1px solid #cccccc;
}

input {
border: 0px solid #cccccc;
}

.values{
font-family: verdana;
font-weight:normal;
font-size : 10px;
align:top;
vertical-align:top;
}

.key{
font-family: verdana;
font-weight:bold;
font-size : 12px;
padding-bottom:15px;
}


.caption{
font-family: Arial, Helvetica, sans-serif;
font-weight:bold;
margin:10px;
font-size : 14px;
color:#C64934;
}

#icon{
width:80px;
height:80px;
float:left;
background-image:url(icon.gif);
background-repeat: no-repeat;
background-position:center center;
}
#icon2{
width:80px;
height:80px;
float:left;
background-image:url(icon2.gif);
background-repeat: no-repeat;
background-position:center center;
}

#source{
text-align:right;
align:right;
padding-right:10px;
font-family: Arial, Helvetica, sans-serif;
font-weight:normal;
font-size : 10px;
color:#CCCCCC;
}






anket/
index.php
polldata.txt
style/
---style.css
---icon.gif
---icon2.gif




i hafli olan icon2.giftir.



Bu sistemi kullanarak kendine göre editlersin. bilgileri polldata.txt ye kayıt ediyor


Kolay gelsin
< Resime gitmek için tıklayın >< Resime gitmek için tıklayın >




Bu mesajda bahsedilenler: @crimsonica
DH Mobil uygulaması ile devam edin. Mobil tarayıcınız ile mümkün olanların yanı sıra, birçok yeni ve faydalı özelliğe erişin. Gizle ve güncelleme çıkana kadar tekrar gösterme.