i have made a server using php. The server is getting new information after some time. I want the server page to display only the current information. when a new information is received, it should delete the previous one and show only the recent. Can you help me in this.
my current code is:
<?php
$fp=fopen("random.txt","a");
fwrite($fp,$_POST['data']."\n");
echo $_POST['data'];
fclose($fp);
?>
Change
atoworr+to write new information each time:The
ameans append which is why you were appending to previous file rather than writing new information.