Important alert: (current site time 7/15/2013 11:27:46 AM EDT)
 

VB icon

Annotate

Email
Submitted on: 10/29/2000 7:47:25 PM
By: PHP Code Exchange  
Level: Intermediate
User Rating: By 4 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 19619
 
     Very simple module to let your users post their comments on your Web pages. Does not require SQL. Does require a writeable directory. by Steve Yelvington
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Annotate
// Description:Very simple module to let your users post their comments on your Web pages. Does not require SQL. Does require a writeable directory. by Steve Yelvington
// By: PHP Code Exchange
//**************************************

<?
/*
annotate.php3 
This is a module that can be placed on any php3 page to allow users to add
their comments. The comments are stored in a file in the current directory,
whose name is constructed by adding ".comment" to the calling page's name,
and merged into the calling page dynamically. (The calling page is not
modified.)
I wrote this because I wanted a simple way to add this functionality to my
pages without requiring that mySQL be available.
In the message input, blank lines are converted to paragraph tags. No other
conversions are applied. If you don't want your users to be able to input
html, uncomment the "strip_tags" line.
Note that the directory must be writable by the web server.
Put this module in some convenient location and then embed it in your pages
like so:
require("/some/full/path/annotate.php3");
or, relative to the docroot:
require($DOCUMENT_ROOT . "/relativepath/php3");
Steve Yelvington <steve@yelvington.com>
*/
if ($message)
	{
	/* uncomment the next two lines to strip out html from input */
	/* $name = strip_tags($name); */
	/* $message = strip_tags($message); */
	$message = ereg_replace("\r\n\r\n", "\n<P>", $message);
	$date = date("l, F j Y, h:i a");
	$message = "<B>$name </B> -- $date<P> $message <BR><HR>";
	$fp = fopen (basename($PHP_SELF) . ".comment", "a");
	fwrite ($fp, $message);
	fclose ($fp);
	}
@readfile(basename(($PHP_SELF . ".comment")));
?>
<FORM method="post">
<b>Your name:</b><BR><INPUT name="name" type="text" size="55"><BR>
<b>Your comment:</b><BR><TEXTAREA name="message" rows=10 cols=55 wrap=virtual>
</TEXTAREA><BR>
<INPUT name="submit" type="submit" value="Post your comments">
</FORM>


Other 192 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
3/26/2003 10:31:23 PMJeff Cook/Moab Software

This code is simple and great, but is there a way to make it so for every page the comments are different. So it is like require(annotate.php?page=news); i want to do something like that.
(If this comment was disrespectful, please report it.)

 
12/5/2004 5:02:17 AM

I added bbcode, badword filter, strip slashes, and spiced up the style a bit

There:
http://junk.slapdot.com/easycomment.phps


(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.