-
[RESOLVED] Textarea
What is wrong with this!
PHP Code:
<?php
echo "<pre>";
echo "<textarea name=\"codeview\" cols=\"80\" rows=\"15\" id=\"codeview\">";
if (!($f=fopen("test.txt","r")))
exit("Unable to open file.");
while (!feof($f))
{
$x=fgetc($f);
echo $x;
}
echo "</textarea>";
echo "</pre>";
fclose($f);
if($_POST['save']){
$code = $_REQUEST['codeview'];
echo "$code";
}
?>
<html>
<form name="save" method="post" action="test.php">
Save.<br>
<input type="submit" name="save" value="Save.">
</form></html>
-
Re: Textarea
Whats happening?? Are you getting an error message of any kind??
BIOSTALL
-
Re: Textarea
No, it isnt echoing what is in the text area. No errors.
-
1 Attachment(s)
Re: Textarea
-
Re: Textarea
The code is supposed to read what is in the text file, then display it on the text area...once I edit the text area and hit save, its supposed to echo w/e is on the text area onto the webpage. The link you sent me doesnt do that.
-
Re: Textarea
try this then:
PHP Code:
<html>
<form name="save" method="post" action="test.php">
<?php
echo "<pre>";
echo "<textarea name=\"codeview\" cols=\"80\" rows=\"15\" id=\"codeview\">";
if (!($f=fopen("test.txt","r")))
exit("Unable to open file.");
while (!feof($f))
{
$x=fgetc($f);
echo $x;
}
echo "</textarea>";
echo "</pre>";
fclose($f);
if($_POST['save']){
echo str_replace("\n", "<br>", htmlspecialchars($_POST['codeview']));
}
?><p>
Save.<br>
<input type="submit" name="save" value="Save.">
</form></html>
check link again: http://www.tkforums.com/test.php