[b]Verbinding.php[/b]

<?php
 $dbhost = "localhost";
 $db = "databasenaam";
 $username = "username";
 $dbww = "pass";
 mysql_connect($dbhost,$username,$dbww);
 mysql_select_db($db);
 ?>

[b]Toon.php[/b]

  <?php
  	include("forum_ubb.php");
	include("verbinding.php");
  	$query = "SELECT Name, Email, Message FROM Guestbook ORDER BY ID Desc";
  	$result = mysql_query($query) or die ("mysql error!");
	$num = mysql_num_rows($result);
 
  while($obj=mysql_fetch_object($result)){
    $name = $obj->Name;
    $email = $obj->Email;
    $msg = $obj->Message;
    ?>
  <table border="1" align="center">
  <tr><td>Geplaatst door:</td>
  <td><?=$name;?></td></tr>
  <tr><td>E-mail:</td>
  <td><?=$email;?></td></tr>
  <tr><td>Bericht:</td>
  <td><?=replace($msg);?></td></tr>
  </table><br />
<?php } ?>

<center><a href="toevoegen.php">Voeg een bericht toe</a></center>
 

[b]toevoegen.php[/b] 

<?php
ob_start();
  include "verbinding.php";
include "forum_ubb.php";
  if ($_POST["submit"]) {
  	if(isset($_COOKIE['gastenboekcookie'])){
		die("Om fout gebruik (flooding / dubbelposts) van het forum te voorkomen kun je slechts 1 bericht per minuut plaatsen.");
		exit();
	}
	$naam = $_POST['naam'];
	  $email = $_POST['email'];
	  $msg = $_POST['msg'];
	
	  $naam = htmlspecialchars($naam);
	  $email = htmlspecialchars($email);
	  $msg = htmlspecialchars($msg);
	
	  $naam = strip_tags($naam);
	  $email = strip_tags($email);
	  $msg = strip_tags($msg);
	/* scheldwoordfilter je kan zelf nog toevoegen */
		$msg = addslashes($msg);
		$msg = eregi_replace('klote','***',$msg);
		$msg = eregi_replace('kut','***',$msg);
           /*einde scheldwoord filter*/
	  $sql = "INSERT INTO Guestbook SET Name='$naam', Email='$email', Message='$msg'";
	  $query = mysql_query($sql) or die("bericht niet geplaatst!");
	  echo "Bericht succesvol geplaatst <a href=\"toon.php\">Ga terug naar het gastenboek</a>";
	  setcookie("gastenboekcookie","geset",time()+100,"/");
  } else { ?>

  <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  Naam: <input type="text" name="naam"><br>
  Email: <input type="text" name="email"><br>
  Bericht: <textarea name="msg" rows="5" cols="30"></textarea><br>
  <input type="submit" name="submit" value="submit">
  </form>
 <?php } ?>
 
[b]forum_ubb[/b] 

<?php
function replace($text){
/*bold*/				$text = preg_replace("#\[b\](.*?)\[/b\]#si","<b>\\1</b>", $text);
/*underline*/			$text = preg_replace("#\[u\](.*?)\[/u\]#si","<u>\\1</u>", $text);
/* italic*/				$text = preg_replace("#\[i\](.*?)\[/i\]#si","<i>\\1</i>", $text);
/*url 1*/				$text = preg_replace("#\[url\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\1</a>", $text);
/*url 2*/				$text = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si","<a href=\\1 target=_blank>\\2</a>", $text);
/*imagetag*/			$text = preg_replace("#\[img\](.*?)\[/img\]#si","<img src=\\1>", $text);
/*align*/				$text = preg_replace("#\[align=(.*?)\](.*?)\[/align\]#si","<p align=\\1>\\2</p>", $text);
/*size*/				$text = preg_replace("#\[size=(.*?)\](.*?)\[/size\]#si","<font size=\\1>\\2</font>", $text);
/*color*/				$text = preg_replace("#\[color=(.*?)\](.*?)\[/color\]#si","<font color=\\1>\\2</font>", $text);
/*face*/				$text = preg_replace("#\[font=(.*?)\](.*?)\[/font\]#si","<font face=\\1>\\2</font>", $text);
/*quote*/				$text = preg_replace("#\[quote\](.*?)\[/quote\]#si",'Citaat:<table border="1" align="right" width="94%" style="background-color:#CCCCCC;border-style:inset;"><tr><td>\\1</td></tr></table><br /><br />', $text);
/*special quote*/		$text = preg_replace("#\[quote=(.*?)\](.*?)\[/quote\]#si", '\\1 zei:<table border="1" align="right" width="94%" style="background-color:#CCCCCC;border-style:inset;"><tr><td>\\2</td></tr></table><br /><br />', $text);
						$text = nl2br($text);
/*smiley's :P */
	$text = str_replace(":arrow:",'<img src="images/forum/yellow/aroow.gif" />',$text);
	$text = str_replace("|)",'<img src="images/forum/yellow/badgrin.gif" />',$text);
	$text = str_replace(":D",'<img src="images/forum/yellow/biggrin.gif" />',$text);
	$text = str_replace(":d",'<img src="images/forum/yellow/biggrin.gif" />',$text);
	$text = str_replace(":-D",'<img src="images/forum/yellow/biggrin.gif" />',$text);
	$text = str_replace(":-d",'<img src="images/forum/yellow/biggrin.gif" />',$text);
	$text = str_replace(":S",'<img src="images/forum/yellow/confused.gif" />',$text);
	$text = str_replace(":?",'<img src="images/forum/yellow/confused.gif" />',$text);
	$text = str_replace(":cool:",'<img src="images/forum/yellow/cool.gif" />',$text);
	$text = str_replace("8)",'<img src="images/forum/yellow/cool.gif" />',$text);
	$text = str_replace(":cry:",'<img src="images/forum/yellow/cry.gif" />',$text);
	$text = str_replace(":'(",'<img src="images/forum/yellow/cry.gif" />',$text);
	$text = str_replace(":\/:",'<img src="images/forum/yellow/doubt.gif" />',$text);
	$text = str_replace(":evil:",'<img src="images/forum/yellow/evil.gif" />',$text);
	$text = str_replace(":!:",'<img src="images/forum/yellow/exclaim.gif" />',$text);
	$text = str_replace(":idea:",'<img src="images/forum/yellow/idea.gif" />',$text);
	$text = str_replace(":)",'<img src="images/forum/yellow/lol.gif" />',$text);
	$text = str_replace(":@",'<img src="images/forum/yellow/mad.gif" />',$text);
	$text = str_replace(":|",'<img src="images/forum/yellow/neutral.gif" />',$text);
	$text = str_replace(":?:",'<img src="images/forum/yellow/question.gif" />',$text);
	$text = str_replace(":P",'<img src="images/forum/yellow/razz.gif" />',$text);
	$text = str_replace(":p",'<img src="images/forum/yellow/razz.gif" />',$text);
	$text = str_replace(":-P",'<img src="images/forum/yellow/razz.gif" />',$text);
	$text = str_replace(":-p",'<img src="images/forum/yellow/razz.gif" />',$text);
	$text = str_replace(":$",'<img src="images/forum/yellow/redface.gif" />',$text);
	$text = str_replace(":roll:",'<img src="images/forum/yellow/rolleyes.gif" />',$text);
	$text = str_replace("8-)",'<img src="images/forum/yellow/rolleyes.gif" />',$text);
	$text = str_replace(":(",'<img src="images/forum/yellow/sad.gif" />',$text);
	$text = str_replace(":-(",'<img src="images/forum/yellow/sad.gif" />',$text);
	$text = str_replace(":sad:",'<img src="images/forum/yellow/sad.gif" />',$text);
	$text = str_replace(":shock:",'<img src="images/forum/yellow/shock.gif" />',$text);
	$text = str_replace(":smile:",'<img src="images/forum/yellow/smile.gif" />',$text);
	$text = str_replace(":o",'<img src="images/forum/yellow/suprised.gif" />',$text);
	$text = str_replace(":O",'<img src="images/forum/yellow/suprised.gif" />',$text);
	$text = str_replace(":-o",'<img src="images/forum/yellow/suprised.gif" />',$text);
	$text = str_replace(":-O",'<img src="images/forum/yellow/suprised.gif" />',$text);
	$text = str_replace(":wink:",'<img src="images/forum/yellow/wink.gif" />',$text);
	$text = str_replace(";)",'<img src="images/forum/yellow/wink.gif" />',$text);
	$text = str_replace(";-)",'<img src="images/forum/yellow/wink.gif" />',$text);
	$text = str_replace("^^",'<img src="images/forum/yellow/^^.gif" />',$text);
/* einde smiley's */
return $text;
}
?>

[b]mysql tabel[/b]

 Create Table Guestbook (
   ID int(10) NOT NULL auto_increment,
   Name Varchar(50) NOT NULL,
   Email Varchar(50) NOT NULL,
   Message Text NOT NULL,
   PRIMARY KEY (ID)
   ) TYPE=MyISAM;
