I have a guestbook for wap which supon execution, stores the data in a .dat file, only problem is the file gets to big for the mobile browser to open. Is there anyway i can change it so that it will only store 10 posts at a time, any older posts will be deleted/overwritten? here is the code
<?php
$filename = "guestbook.dat";
$file = "index.php?s=" . date('U');
$name = $_POST['name'];
$message = $_POST['message'];
if ($message) {
$name = strip_tags($name);
$message = strip_tags($message);
$name = StripSlashes($name);
$message = StripSlashes($message);
$message = ereg_replace("\r\n\r\n", " ", $message);
// $date = date("l, F j Y, H:i");
$date = date('d/M/Y H:i');
$message = "$name<br/>$date<br/>$message<br/>---<br/>";
$fp = fopen($filename, "r");
$gb = fgets($fp);
fclose($fp);
$guestbook = "$message" . "$gb";
$fp = fopen ($filename, "w");
fwrite ($fp, $guestbook);
fclose ($fp);
}
header('Content-type: text/vnd.wap.wml');
echo '<?xml version="1.0" encoding="iso-8859-1"?>' . "\n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="no-cache"/>
</head>
<card id="post" title="Message Posted" ontimer="<?php
echo $file?>" >
<timer value="1"/>
<p align="center">
Please Wait....
<br/>
</p>
</card>
</wml>
Thanks for anyhelp ppl