Ok - to replicate exactly what I've got, which is a slightly altered version of Paul Gareau's simple shoutbox script (with things you need to change highlighted by //change this to the right of a line) for your site you'd do the following:
In your HTML page you'd have the following added at the point where you want your comments to appear:
<?php include("simplemb.inc.php");
do_board(); ?>
You also need a .txt file which you call board.txt - this is the file that will contain the comments that your users leave.
Finally you need a PHP file as follows:
<?php
/*
Paul Gareau - paul@xhawk.net
Copyright (C) 2001 - Paul Gareau
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
###################################################
# simplemb v.1.1.0
#
# to use put the following lines in your code: #
#
# include("simplemb.inc.php");
# do_board();
#
# #
# make sure your data file can be written to #
# by yourserver! #
# #
# you can customize the look and feel of the #
# script by changing the following variables #
###################################################
########################
# EDIT THESE VARIABLES #
########################
$filename = 'board.txt';;
$dark_background = '#DDDDDD';
$light_background = '#EEEEEE'; // These colour options don't work in my version so ignore them
$sfont = $font2;
#################
# MAIN FUNCTION #
#################
function do_board($num=20)
{
global $show,
$mb_submit,
$name,
$message,
$PHP_SELF;
global $filename,
$dark_background,
$light_background,
$lfont,
$sfont;
if($mb_submit && $name && $message) //add post to data file
{
$name = stripslashes(strip_tags($name));
$message = stripslashes(strip_tags($message));
$message = ereg_replace("[[:space:]]+", ' ', $message);
$message = str_replace("|", '', $message);
$ary_date = getdate(time());
$date = $ary_date['mday'].'.'.$ary_date['mon'].'.'.$ary_date['year'];
$new = $name.'|'.$date.'|'.$message;
$fp = fopen($filename, "a");
fwrite($fp, $new."\n");
fclose($fp);
echo
"$sfont\n".
"Your Caption wasentered.\n". // change to whatever you want - maybe "Your Comment wasentered"
"<br />\n".
"<br />\n".
"<ahref='$PHP_SELF'><strong> » Return to CaptionCompetition</strong></a>.\n". // change to Back to CommentPage
"<br />\n".
"<br />\n".
"[ Opera users please refreshyour page <strong>after</strong> returning to the CaptionList to see your caption ]\n" //I added this line because I was gettingproblems with Opera
;
}
elseif($show=="form") //show post form
{
echo
"$sfont\n".
"Enter your name andCaption, then press 'Enter' to post.\n". //Change this to Enter nameand Comment...
"<br />\n".
"<br />\n".
"<ahref='$PHP_SELF'>Return to Caption Competition</a>\n". //change this to return to Comment Page etc
"<form action='$PHP_SELF' method='post'>\n".
"<table cellpadding='0' cellspacing='0'><tr><td>\n".
"$sfont\n".
"Name: \n".
"<br />\n".
"<input type='text' name='name' size='20'>\n".
"<br />\n".
"Message:\n".
"<br />\n".
"<textarea rows='2'cols='50' name='message' wrap='virtual'></textarea>\n".
"</tr></td><tr><td>\n".
"$sfont\n".
"<input type='submit' value='Enter' name='mb_submit'>\n".
"<input type='reset' value='clear'>\n".
"</td></tr></table>\n".
"</form>\n";
}
else //show posts
{
$ary_board = file($filename);
$num_lines = count($ary_board);
echo "<table cellpadding='5' cellspacing='0' width='80%'>\n";
for($line_num=($num_lines>$num)?$num_lines-$num:0; $line_num <$num_lines; $line_num++)
{
if(! ereg("^[[:space:]]+$", $ary_board[$line_num]))
{
$ary_fields = explode("|", $ary_board[$line_num]);
$name = $ary_fields[0];
$date = $ary_fields[1];
$message = $ary_fields[2];
if(++$line % 2) $color = $dark_background;
else $color = $light_background;
echo
"<tr><td>\n".
"$sfont\n".
"<b>$name - $date</b>\n".
"<br />\n".
"$message\n".
"</td></tr>\n";
}
}
echo
"</table><br />\n".
"$sfont <h5><ahref='$PHP_SELF?show=form'>» Enter aCaption</a></h5>\n"; //change this to Enter a Comment orwhatever
}
} //end function
?>
This is my fiddled with version to get it to validate - for the original version with alternate colour stripes etc then download the original from http://xhawk.net/projects/simplemb/
I've added comments where I think you should change stuff.
Copy and Paste this code to a new totally blank notepad page and save it as simplemb.inc.php then upload it to your web server - make sure you do this in ASCII mode or it won't work. To keep things simple upload it to the same directory as your comments page.
Upload the other files too. You'll need to edit the chmod (permissions) on the board.txt file so that people can add their comments. In a FTP programme usually you can right-click on the file on your web server and choose properties then their may be a list of boxes you can tick - tick 'em all. There may also be a 3 figure number - it should read 777. Change this and now people can add stuff to the file. If you can't do the right-click thing then have a look at the options on your programme - you're looking for Permissions of CHMOD.
Have a look and see if it works.
If when you open the page there's no "Enter Comments" link then add the following to your .htaccess file:
AddType application/x-httpd-php .php .html
Your .htaccess file is in your root directory of your web server.
Have a go with a test page and see how you go. The good thing about PHP is that if you've got something wrong it usually throws up useful error messages - so it's easier to work out what's wrong.