My online chat uses a php script. There`s the part I need to correct
if(isset($_SESSION['name']) && $_POST['text'] != ""){
$search = "";
$aname = $_SESSION['name'];
function find_value($input) {
$handle = fopen("online.html", "r");
if ($handle) {
while (!feof($handle)) {
$entry_array = explode(" ",fgets($handle));
if ($entry_array[0] == $input) {
$search = $entry_array[0];
}
}
fclose($handle);
}
RETURN NULL;
}
find_value($aname);
if($search == "") {
$handle = fopen("online.html",'r');
$contents = fread($handle,filesize("online.html"));
fclose($handle);
$handle = fopen("online.html",'w');
fwrite($handle,$contents." <BR> ".$_SESSION['name']);
fclose($handle);
}
My problem is, so when somebody submits a message, his name is written into online.html as many times, as he writes something. But i need to write it only ones, because all that names in online.html will appear on my site as logged in users. Please help me to correct it. I need to all names appear in online.html only once.