it can easily be done using php and either mysql or a simple text file.
javascript is more for dynamic on the fly, such as effects on websites. javascript by itself cannot modify any files though, as it does not have the permissions to.
a sample mysql guestbook:
PHP Code:
<?php
mysql_connect('localhost', 'username', 'password');
mysql_select_db('dbname');
if (isset($_POST['submit']))
{
$name = $_POST['name'];
$comment = $_POST['comment'];
$email = $_POST['email'];
if (empty($name) || empty($comment) || empty($email))
echo 'You left a field empty.<br /><a href="javascript:history.go(-1)">Go back</a>';
else
{
$db = mysql_query("INSERT INTO guestbook ('name', 'comment', 'email') VALUES('".$name."', '".$comment."', '".$email."')");
if ($db)
echo 'Thank you for your comment.<br /><a href="'.$_SERVER['PHP_SELF'].'">Continue</a>';
else
echo 'There was an error submitting your comment';
}
}
$result = mysql_query('SELECT name, comment FROM guestbook ORDER BY id DESC LIMIT 5');
while ($gb = mysql_fetch_assoc($result))
{
echo '<p>',$gb['name'],':<br />',$gb['comment'],'</p>';
}
echo <<<eof
<form action='' method='post'>
<fieldset>
<legend>Leave a comment</legend>
<div>
<input name='name' type='text' /> Your Name<br />
<input name='email' type='text' /> Your Email (Kept Private)<br />
<textarea name='comment'></textarea> Your Comment<br /><br />
<input name='submit' value='Submit Comment' type='submit' />
</div>
</fieldset>
</form>
eof;
?>