Flash Database Step By Step Tutorial - Part 2: In this post, we prepare server side use PHP. There are 3 task of PHP: read data, update data, and display text.
First, we talk about reading data. Create a file named "polling.php" within www/test/flash. Enter with following code:
<?
$file_data = "polling.txt";
// prepare no cache
header("Expires: Mon, 01 Jan 1990 00:00:00 GMT");
header("Last-Modified: ". gmdate("D, d M Y h:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0; pre-check=0", false);
header("Pragma: no-cache");
function readData(){
global $file_data;
$fp = file($file_data);
while(list($line, $value) = each($fp)){
print "&" . eregi_replace("\r\n","",$value);
}
}
readData();
?>
Try to open it. Point your browser to http://localhost/test/flash/polling.php. You may get like this:
&title=What database kind do you like?&choice1=Plain Text&choice2=XML&choice3=MySQL&choice4=MsSQL&choice5=Oracle&choice6=SQLite&choice7=PostgreSQL&choice8=Ms Access&choice9=DB4O&choice10=Db2&votes1=0&votes2=0&votes3=0&votes4=0&votes5=0&votes6=0&votes7=0&votes8=0&votes9=0&votes10=0&allow=true
This text will read by flash.