Ok, its kinda messy, i understand that... if anyone has another way of doing it, i'm sure it can be done more efficiently...
Basically my problem is that after you submit your thing, the data still stays there (as in, if you press refresh, it updates the thing again, with what was previously in there...). How do i go about clearing what's in the boxes? so that if refresh is pressed, it wont display the same thing...
(hope this makes sense, i didnt explain it to well).
Anywho, here's the code:
Code: Select all
<?
$chat_file_ok = "ideas.txt";
$chat_length = 25;
$max_single_msg_length = 100000;
$max_file_size = $chat_length * $max_single_msg_length;
$file_size= filesize($chat_file);
if ($file_size > $max_file_size)
{
$lines = file($chat_file_ok);
$a = count($lines);
$u = $a - $chat_length;
for($i = $a; $i >= $u ;$i--)
{
$msg_old = $lines[$i] . $msg_old;
}
$deleted = unlink($chat_file_ok);
$fp = fopen($chat_file_ok, "a+");
$fw = fwrite($fp, $msg_old);
fclose($fp);
}
$person = str_replace ("\n"," ", $person);
$person = str_replace ("<", " ", $person);
$person = str_replace (">", " ", $person);
$person = stripslashes ($person);
$msg = str_replace ("\n"," ", $message);
$msg = str_replace ("<", " ", $msg);
$msg = str_replace (">", " ", $msg);
$msg = stripslashes ($msg);
if ($msg != "" && $msg != "Quote" && $person != "Author" && $person != "" )
{
$fp = fopen($chat_file_ok, "a+");
$fw = fwrite($fp, "\n"$msg" - $person<br>");
fclose($fp);
}
$lines = file($chat_file_ok);
$a = count($lines);
$u = $a - $chat_length;
for($i = $a; $i >= $u ;$i--)
{
echo "$lines[$i]";
}
?>