I would like to save to database but not file. please help me and show me how i can change from file to databasetables.
****users*****
<?php
function saveUsers($onlineusers_file){
$file_save=fopen("onlineusers_".$_POST…
flock($file_save,LOCK_EX);
for($line=0;$line<count($onlineusers_f…
fputs($file_save,$onlineusers_file[$li…
};
flock($file_save,LOCK_UN);
fclose($file_save);
}
$onlineusers_file=file("onlineusers_".…
if (isset($_POST['user'],$_POST['oper'])){
$user=$_POST['user'];
$oper=$_POST['oper'];
$userexist=in_array($user,$onlineusers…
if ($userexist)$userindex=array_search($use…
if($oper=="signin" && $userexist==false){
$onlineusers_file[]=$user;
saveUsers($onlineusers_file);
echo "signin";
exit();
}
if($oper=="signin" && $userexist==true){
echo "userexist";
exit();
}
if($oper=="signout" && $userexist==true){
array_splice($onlineusers_file,$userin…
saveUsers($onlineusers_file);
echo "signout";
exit();
}
if($oper=="signout" && $userexist==false){
echo "usernotfound";
exit();
}
}
$olu=join("<br>",$onlineusers_file);
echo $olu;
?>
*****send*******
<?php
$message=strip_tags($_POST['message'])…
$message=stripslashes($message);
$user=$_POST['user'];
$touser=$_POST['touser'];
$room="room_".$_POST['room'].".txt";
$room_file=file($room,FILE_IGNORE_NEW_…
$room_file[]=time()."<!@!>".$user."<!@…
if (count($room_file)>20)$room_file=array_s…
$file_save=fopen($room,"w+");
flock($file_save,LOCK_EX);
for($line=0;$line<count($room_file);$l…
fputs($file_save,$room_file[$line]."\n…
};
flock($file_save,LOCK_UN);
fclose($file_save);
echo "sentok";
exit();
?>
*******receive*********
<?php
$lastreceived=$_POST['lastreceived'];
$user=$_POST['user'];
$room="room_".$_POST['room'].".txt";
$room_file=file($room,FILE_IGNORE_NEW_…
$pattern = '/:(\w+):/';
$replacement = "<img src='./emotions/$1.png' />";
$hasMessage=false;
for($line=0;$line<count($room_file);$l…
$messageArr=explode("<!@!>",$room_fil…
if(count($messageArr)>1){
$touser=$messageArr[2];
if(in_array($user,explode(",",$messa… || $user==$messageArr[1] || $touser==""){
if($messageArr[0]>$lastreceived){
echo $messageArr[1].": ".preg_replace($pattern,$replacement,$me…
$hasMessage=true;
}
}
}
}
echo ($hasMessage)?"<SRVTM>".$messageArr[0]:"…
?>