fopen file not updating inside textarea [fixed]
Posted: Tue Jul 15, 2003 10:43 am
The script's purpose is to show $_GET['filename'] inside a textarea, and when the submit button is clicked, the file is edited and the stuff in the textarea SHOULD appear with the updated file.
For some reason however, when edit is pressed the content in the textarea is not updated like I want it to be. It remains the same until I refresh the page.
Is there any way of fixing this behaviour?
Here's the rough code.
For some reason however, when edit is pressed the content in the textarea is not updated like I want it to be. It remains the same until I refresh the page.
Is there any way of fixing this behaviour?
Here's the rough code.
Code: Select all
function edit_file() {
print '<form method=''POST''>';
print 'Editing ./'.$_GETї'filename'].'<br>';
print 'Content: <textarea name=''create_content'' style=''width:400px;height:300px;''>';
$fpr = fopen('./'.$_GETї'filename'],'r');
while (!feof($fpr)){
print fgetc($fpr);
}
fclose($fpr);
print '</textarea><br>';
print '<input type=''submit'' value=''Create''>';
print '</form>';
if ($_GETї'filename']){
if ($_POSTї'create_content']) {
$fpw = fopen($_GETї'filename'],'w');
fwrite($fpw,$_POSTї'create_content']);
fclose($fpw);
print 'Content has been written into the file.<br>';
}
}
}