PHP Form - Edit & Delete via Text File Db
- by Jax
hi,
I pieced together the script below from various tutorials, examples, etc...
Right now the script currently:
Saves Id, Name, Url with a "|" delimiter to a text file Db like:
1|John|http://www.john.com|
2|Mark|http://www.mark.com|
3|Fred|http://www.fred.com|
But I'm having a hard time trying to make the "UPDATE" and "DELETE" buttons work.
Can someone please post code which will:
let me update/save any changed data for that row (for UPDATE button)
let me delete that row (for DELETE button)
PLEASE copy n paste the code below and try for yourself.
I would like to keep the output format of the script below too.
thanks
D-
$file = "data.txt";
$name = $_POST['name'];
$url = $_POST['url'];
$data = file('data.txt');
$i = 1;
foreach ($data as $line) {
$line = explode('|', $line);
$i++;
}
if (isset($_POST['submits'])) {
$fp = fopen($file, "a+");
fwrite($fp, $i."|".$name."|".$url."|\n");
fclose($fp);
}
?
');
}
?