Can php populate a html form?
Posted: Wed Mar 15, 2006 10:15 am
Hi, I have written some php code to pass the contents of a text document to a variable.
I now need to populate a form text area with that variable but am not sure how to do it as I am new to php.
My code looks like this:
It is a mess at the moment as you can see. All I am trying to do is get some text from a text file into my form. Any help would be gratefully recieved.
Thanks,
Andy.
I now need to populate a form text area with that variable but am not sure how to do it as I am new to php.
My code looks like this:
Code: Select all
<FORM action="savetodb.php" method="post">
Update Wiki:<BR>
<TEXTAREA name="wiki_text" cols="100" rows="30"></TEXTAREA><BR>
<INPUT type="submit" value="Update Wiki">
<?php
$filename="wiki.data";
$fp = @fopen($filename, "r") or die("Couldn't open file");
$data = fread($fp, filesize($filename));
while(!feof($fp))
{
$data .= fgets($fp, 1024);
}
fclose($fp);
$values = explode("\r\n", $data);
TEXTAREA name="wiki_text" value=$data;
?>
</FORM>Thanks,
Andy.