Jump to content
Norman

Guestbook Script

Recommended Posts

i used this one...so, you create a new PHP file named addbook.php , which code is this:

<?php(isset($_POST['message']))?$message=$_POST['message']:$message='';(isset($_POST['name']))?$name=$_POST['name']:$name="";if ($message != ''){  $message = str_replace ("\n","<br>",$message);  $message = strip_tags ($message, '<br>');  $newRow = '<div class="viewGuestbook">' . ($message) .		  '<br>' . date('d.m.Y H:i') . ' - ' . strip_tags ($name) .		  '</div>';		    $oldRows = join ('', file ('guestbook.txt') );  $fileName = fopen ('guestbook.txt', 'w');  fputs ($fileName, $newRow . chr(13) . chr(10) . $oldRows);  fclose ($fileName);}include ("readbook.php");?>

next one: readbook.php :

<div class="guestbookTop"><a href="postform.php">Write</a> to a guestbook<br><br></div><?php$fileName = file ("guestbook.txt");$rows = count ($fileName);  if ($rows > 10){	if (!isset ($row) )	{		$row = 0;	}	print ("<table class=\"guestbookLinks\"><tr><td width=\"50%\">");  	if ($row > 0)	{		echo "<div class=\"nextPage\"><< <a href=\"readbook.php?row=" . ($row - 10) . "\">Next 10</a></div>";	}		print ("</td><td width=\"50%\">");	if ( ($rows - $row) > 10)	{		echo "<div class=\"previousPage\"><a href=\"readbook.php?row=" . ($row + 10) . "\">Previous 10</a> >></div>";	}			print ("</td></tr></table>");	   for ($i = $row; $i < ($row + 10); $i++)	{		echo $fileName [$i];	}}else{	  for ($i=0; $i < $rows; $i++)	  {		  echo $fileName [$i];	  }}  ?><div class="guestbookUp"><br><br><br><br>	<a href="postform.php">Write</a> to a guestbook</div>

and postform.php :

<div class="normalText"><form action="addbook.php" method="post">Message<br><br><textarea name="message" cols="50" rows="7" class="textbox"></textarea><br><br>Name<br><br><input type="text" name="name" size="48" class="textbox"><br><br><input type="submit" value=" Submit " class="textbox"></form></div>

And also create a .txt file named guestbook.txt , where the messages from your guestbook will be saved...It's not smth sophosticated, but it's good enough :)

Share this post


Link to post
Share on other sites

Yes. Mhh, I think I will download a simple script.. and I will take the tame to edit the HTML code in order to have something more pretty and unique.

Share this post


Link to post
Share on other sites

what language do you want to code it in?

Share this post


Link to post
Share on other sites

You can't create a guestbook with just CSS, as CSS can't perform actions, respond to events (more than through pseudo-classes), or save and retreive text data. You will need to use a server-side language to save the comments.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...