You Are Here: Home »   Code Tuesday January 6th 2009

Code Library - php

Add text to text file - (2366 views)


<form action="<? $PHP_SELF ?>" method="post">
<br><input type="text" name="name" value="Name"><br>
<textarea type="text" name="comm">
Add Your Comment
</textarea><br>
<input type="submit" value="Add">
<?

//ALL You need is to create comment.txt file, and give CHMOD 777

$date date("d.m.Y");
if (!isset (
$comm) && ($name)){
    
$fp fopen("comment.txt","a+");
    
fwrite($fp,nl2br("<meta http-equiv=Content-Language content=hr><table border=1 width=276 height=16><td width=128 height=4>Name:$name</td><td width=132 height=4>Date:$date</td><tr><td width=266 height=9 colspan=2>$comm</td></tr></table><br>"));
    
fclose($fp);
}
?>
Messages:
<?
readfile 
("comment.txt");
?>