<?php
error_reporting(E_ALL);
ob_start();
include ("functies.php");
include ("config.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Schrijf een bericht in het gastenboek</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
//Deze functie hebben we later nodig voor de UBB code
function Invoegen(Smiley) {
var edit;
var HuidigeTekst = document.gastenboek.bericht.value;
edit = HuidigeTekst+Smiley+" ";
document.gastenboek.bericht.value=edit;
document.gastenboek.bericht.focus();
return;
}
function smiley() {
return;
}
</script>
</head>
<body>
<?php
if (isset($_POST['Submit'])) {
if (!trim($_POST['naam'])) {
$error="Je moet je naam invullen";
}
elseif(!check_email($_POST['emailadres'])) {
$error="Je moet een geldig e-mailadres invullen";
}
elseif (!trim($_POST['bericht'])) {
$error="Je moet een bericht invullen";
}
elseif ($_COOKIE['Gastenboek'] == "1") {
$error="Je kan geen bericht posten omdat je er al één hebt gepost";
}
//Als er een veld niet is ingevuld of wanneer het e-mailadres niet bestaat komt er een error
if ($error != "") {
?>
<center>
<table class="gastenboek" width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td>
<center>
<b><?=$error?></b><br>
<form method="post" action="javascript:history.go(-1)">
<input type="submit" name="Terug" value="Terug" />
</form>
</center>
</td>
</tr>
</table>
</center>
<?php
} else {
//Als alles correct is ingevuld gaan we over naar het posten van de gegevens naar de database
mysql_query ("INSERT INTO gastenboek (naam, emailadres, website, bericht, datum) VALUES ('".$_POST['naam']."', '".$_POST['emailadres']."', '".$_POST['website']."', '".$_POST['bericht']."', NOW())") or die (mysql_error());
//Om SPAM te vermijden maken we een COOKIE (zie config)
setcookie (Gastenboek, 1, $tijd_cookie);
//Na het verzenden sturen we de gebruiker terug naar het gastenboek
header ("location: ".$pagina_lezen);
}
} else {
?>
<center>
<form name="gastenboek" action="" method="post">
<table class="gastenboek" width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td height="20" colspan="2"><strong>Bericht posten in het gastenboek:</strong></td>
</tr>
<tr>
<td width="44%">Naam:</td>
<td width="56%">
<input name="naam" type="text" id="naam" size="30" maxlength="50" />
</td>
</tr>
<tr>
<td>Website:</td>
<td>
<input name="website" type="text" id="website" value="http://" size="30" maxlength="50" /><br />
<font style="color: #FF0000">(<strong>niets invullen</strong> als je<strong> geen website</strong> hebt)</font>
</td>
</tr>
<tr>
<td>E-mail adres:</td>
<td>
<input name="emailadres" type="text" id="emailadres" size="30" maxlength="50" />
</td>
</tr>
<tr>
<td align="center" colspan="2">Bericht:</td>
</tr>
<tr>
<td align="center" colspan="2">
<table width="27%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" height="21" colspan="4">
<small><i><b>Ubb-code:</b></i></small>
</td>
</tr>
<tr>
<td align="center" height="27" colspan="4">
<input type="button" name="b" value="B" style="font-weight: bold; width: 30px;" onclick="javascript:Invoegen('[B]...[/B]');" />
<input type="button" name="u" value="U" style="text-decoration: underline; width: 30px;" onclick="javascript:Invoegen('[U]...[/U]');" />
<input type="button" name="i" value="I" style="font-style: italic; width: 30px;" onclick="javascript:Invoegen('[I]...[/I]');" />
<input type="button" name="s" value="S" style="text-decoration: line-through; width: 30px;" onclick="javascript:Invoegen('[S]...[/S]');" />
<input type="button" name="url" value="http://" onclick="javascript:Invoegen('[URL=http://...]...[/URL]');" />
</td>
</tr>
<tr>
<td align="center" height="21" colspan="4">
<input type="button" name="align" value="Align" onclick="javascript:Invoegen('[ALIGN=...]...[/ALIGN]');" />
<input type="button" name="color" value="Kleur" onclick="javascript:Invoegen('[COLOR=...]...[/COLOR]');" />
<input type="button" name="size" value="Grootte" onclick="javascript:Invoegen('[SIZE=...]...[/SIZE]');" />
<input type="button" name="e-mail" value="E-mail" onclick="javascript:Invoegen('[EMAIL=...]...[/EMAIL]');" />
</td>
</tr>
<tr>
<td align="center" height="21" colspan="4"><small><i><b>Smileys:</b></i></small></td>
</tr>
<tr>
<td height="41" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onclick="javascript:Invoegen(':)');"><img src="pages/gastenboek/3/smileys/blij.gif" width="20" border="0" /></a></td>
<td height="41" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onclick="javascript:Invoegen(':D');"><img src="pages/gastenboek/3/smileys/tanden.gif" width="20" height="20" border="0" /></a></td>
<td height="41" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onclick="javascript:Invoegen(':P');"><img src="pages/gastenboek/3/smileys/tong.gif" width="20" height="20" border="0" /></a></td>
<td height="41" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onclick="javascript:Invoegen(';)');"><img src="pages/gastenboek/3/smileys/knipoog.gif" width="20" height="20" border="0" /></a></td>
</tr>
<tr>
<td height="36" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onclick="javascript:Invoegen(':cool:');"><img src="pages/gastenboek/3/smileys/cool.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onclick="javascript:Invoegen(':s');"><img src="pages/gastenboek/3/smileys/verward.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onclick="javascript:Invoegen(':omg:');"><img src="pages/gastenboek/3/smileys/omg.gif" width="20" height="20" border="0" /></a></td>
<td height="36" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onclick="javascript:Invoegen(':(');"><img src="pages/gastenboek/3/smileys/droevig.gif" width="20" height="20" border="0" /></a></td>
</tr>
</table>
<br>
<textarea name="bericht" cols="50" rows="10" id="bericht"></textarea><br />
</td>
</tr>
<tr>
<td height="25" colspan="2" align="center">
<input type="submit" name="Submit" value="Verzenden" />
<input name="Reset" type="submit" id="Reset" value="Opnieuw" />
</td>
</tr>
</table>
</form>
</center>
<?php
}
?>
</body>
</html>