In order for that data to be updated, you must read that data to some variable and just alter that data within some textarea and just write back that data.
All that could be done with simple Input/Output php file IO calls.
For Example. Lets assume your data is 'file.txt', so lets save that file to some variable 'filePage'
======================
$filePage ="file.txt";
======================
Now since you have created the html
=====================
// Check if a POST Form variable (textarea) named txtDescription has been sent
if (isset($_POST['txtDescription']) )
// Lets open the 'file.txt' as a stream and apply write privilege
$fp = fopen("$filePage", "w");
// Now lets write it down the contents of the 'textarea' to that stream
fwrite($fp, stripslashes($_POST['txtDescription']));
// Now close the file
fclose($fp);
}
======================
To read the file again and post it to the screen you could do the following
======================
// Open the file to the stream
$fp = fopen("$filePage", "r");
// Lets read until end of file
while (!feof($fp)) {
// Lets just place all data (buffer) into the variable 'data'
$data .= fgets($fp, 4096);
}
// Close the stream
fclose($fp);
======================
So an application that will allow you to modify or update a file.txt could be something like this:
Save as file.php
+++++++++++++++++++++++++
=========================
// Name of your file
$filePage ="file.txt";
// Test if Form Submission has been set
if (isset($_POST['newdata']) && isset($_POST['submit']) && $_POST['submit']) {
// Open File with write privileges
$fp = fopen("$filePage", "w");
// Write Contents
fwrite($fp, stripslashes($_POST['newdata']));
// Close File
fclose($fp);
}
// Now Lets reopen the file with read privileges
$fp = fopen("$filePage", "r");
// Read the entire file until end of file
while (!feof($fp)) {
// Store it to data variable (buffer)
$data .= fgets($fp, 4096);
}
// Close File
fclose($fp);
?>
Yahoo! Answers File I/O Administration
=========================
+++++++++++++++++++++++++
Hope that helped you a bit.
Good Luck, if you need more advice don't hesitate to ask :)
2007-01-29 09:30:24
·
answer #1
·
answered by ? 6
·
0⤊
0⤋
No, because we have no idea what you want to write. Post what code you have to a text file, put it on a Web site, post a link to the text file here, then ask specific questions.
2007-01-28 22:19:32
·
answer #2
·
answered by Anonymous
·
0⤊
1⤋