thank you for your reply but i think that what u posted isnt going to accomplish what I want it to...
I will try to restate because the problem is probably ME 😛
basically this is what i think will be what i WANT
I want (as it currently does) the submit to add the chat to the bottom of the text file.
THEN (or before) the php will check the txt document. If it has 10 lines of chat then it will remove the top one (in my case the one that is the oldest)
this is my chat.php which is loaded in a frame and posts the data entered in the chat...
<head><link href="../chrislive.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="5898C4" topmargin="0">
<div align="center">
<?
echo '<HTML>';
// Chat Display
if (!isset($_POST[name])) {
print "<body onload=\"document.chatForm.name.focus();\">";
print "<FORM ACTION=\"chat.php\" METHOD=\"POST\" NAME=\"chatForm\">";
print "<font color=\"#6A6A6A\" size=\"2\" face=\"Arial\"><B>name:</B></font> <INPUT TYPE=\"text\" NAME=\"name\" MAXLENGTH=50> ";
}
else {
print "<body onload=\"document.chatForm.chat.focus();\">";
print "<FORM ACTION=\"chat.php\" METHOD=\"POST\" NAME=\"chatForm\">";
if ($_POST[name]=="") {
$_POST[name]="anonymous";
}
}
print "<font color=\"#6A6A6A\" size=\"2\" face=\"Arial\"><B>name:</B></font> <font color=\"#000000\" size=\"2\" face=\"Arial\">$name</font> <INPUT TYPE=\"hidden\" NAME=\"name\" VALUE=\"$name\">";
$fp=fopen("./userlog.txt",'a');
$fs="nickname: $name\nIP: $_SERVER[REMOTE_ADDR]\nISP: $_SERVER[REMOTE_HOST]\nUser Agent: $_SERVER[HTTP_USER_AGENT]\nMessage: $chat";
fputs($fp,$fs);
fclose($fp);
$fp = fopen($_POST['name'] . '.usr','w');
fputs($fp,'');
fclose($fp);
}
print "<font color=\"#6A6A6A\" size=\"2\" face=\"Arial\"><B>message:</B></font> <INPUT TYPE=\"text\" NAME=\"chat\" size=\"40\" MAXLENGTH=250> <INPUT TYPE=\"submit\" VALUE=\"Send!\"> ";
if ($_POST[chat]!="") {
$old=file_get_contents("livechat.txt");
$fp=fopen("livechat.txt",'w');
$colfnt = array ("[blue]","[black]","[green]","[red]","[gray]","[pink]","[orange]","[white]");
$ccolfnt = array ("</FONT><font color=\"blue\" size=\"2\" face=\"Arial\">","</FONT><font color=\"black\" size=\"2\" face=\"Arial\">","</FONT><font color=\"green\" size=\"2\" face=\"Arial\">","</FONT><font color=\"red\" size=\"2\" face=\"Arial\">","</FONT><font color=\"grey\" size=\"2\" face=\"Arial\">","</FONT><font color=\"#pink\" size=\"2\" face=\"Arial\">","</FONT><font color=\"orange\" size=\"2\" face=\"Arial\">","</FONT><font color=\"#FFFFFF\" size=\"2\" face=\"Arial\">");
$uc = $_POST['chat'];
$uc = strip_tags($uc,'<b><i><tt><u><del><a>');
$uc = str_replace ( ":)", "<IMG SRC=\"smilies/smile.gif\">", $uc );
$uc = str_replace ( ":(", "<IMG SRC=\"smilies/sad.gif\">", $uc );
$uc = str_replace ( ";)", "<IMG SRC=\"smilies/wink.gif\">", $uc );
$uc = str_replace ( $colfnt, $ccolfnt, $uc );
$uc = $uc . "</FONT>";
$_POST[name] = strip_tags($_POST[name]);
$tw="$old \n \n<font color=\"#000000\" size=\"2\" face=\"Arial\"><b>< </b><font color=\"#FFFFFF\" size=\"2\" face=\"Arial\"><b>$_POST[name]</b></font> <font color=\"#000000\" size=\"2\" face=\"Arial\"><b>></b> <font color=\"#FFFFFF\" size=\"2\" face=\"Arial\">$uc</font><br>";
$ttw=stripslashes($tw);
fputs($fp,$ttw);
fclose($fp);
unset($chat);
}
?>
</div>