This is saving function. Add to polling.php:
function saveData(){
global $file_data;
if(number_format($_GET['num']) < 1) die("registered=false");
// open file
$fp_array = file($file_data);
$fp = fopen($file_data,"r+");
$temp_string = "";
// read file
foreach($fp_array as $key => $value){
// extract each lines
$line = explode('=', $value);
$name = $line[0];
$val = eregi_replace("\r\n","",$line[1]);
// if as votes
if(substr($name,0,5)=='votes'){
$val = (int)eregi_replace("\r\n","",$line[1]);
$match= (int)(substr($name,5,2));
// if the index same as choice, add 1
if($match == $_GET['num']){
$val++;
}
}
// write this line
$temp_string .= $name."=".$val."\r\n";
}
fwrite($fp, $temp_string);
fclose($fp);
}
| Series this article: Flash Database: Text File Flash Database: PHP for Reading Data Flash Database: Saving Data at Server Side Flash Database: Switching Task at Server Side Flash Database: Starting Flash Flash Database: Making Flash Polling Interface Flash Database: Giving Action to Submit Polling Flash Database: Trying Submiting Vote Flash Database: Preparing Polling Result Interface Tag: flash, database, server side Category: PHP Application Post : March 24th 2008 Read: 2,061 blog comments powered by Disqus |