Posted by samudasu on 02/19/06 11:20
This code will delete your messages. It's coded for php5. If you're
running php4 then you'll have to substitute fopen, fwrite, and fclose
for file_put_contents.
shownews.php..........
<?php
$data = file('news.txt');
foreach ($data as $key => $value) {
print "$value: <a href=\"delnews.php?del=$key\">delete</a><br
/>\n";
}
?>
delnews.php.............
<?php
$file = 'news.txt';
$data = file($file);
unset($data[$_GET['del']]);
print "<pre>";
print_r($data);
print "</pre>";
file_put_contents($file, $data);
?>
Navigation:
[Reply to this message]
|