<?php
include_once ("cfg/functions.php");
loginuser();
echo('<form id="gbook" name="gbook" method="post" action="index.php?p=gbook">');
echo('<textarea name="guestbook" rows="5" cols="25"></textarea>');
echo('<br>');
echo('<input name="submit" type="submit" class="liteoption" id="submit" value="Abschicken"/>');
echo('<input name="submit2" type="submit" class="liteoption" id="submit" value="Alle zeigen"/>');
echo('</form>');
if(isset($_POST['submit'])) {
if(!$_POST['guestbook']) {
die('<tc>bitte was eintragen!</tc>');
}
else {
connect();
$datum = (date('d.m.y H:i:s'));
$text = strip_tags($_POST['guestbook']);
if(!$text) {
die('<tc>Code ist nicht erlaubt!</tc>');
}
else {
$user = ($_SESSION["User"]);
$ieintrag = mysql_query("INSERT INTO guestbook (author, date, text) VALUES ('$user', '$datum', '$text')");
echo ('<tc>Gästebuch eintrag geschrieben...</tc><meta http-equiv="refresh" content="2; url=index.php?p=gbook">');
}
}
if(isset($_POST['submit2'])) {
echo('<b><font size="+1"><tc>Alle Einträge</tc></font></b><br><br>');
connect();
$menu = mysql_query("SELECT ID, author, date, text FROM guestbook ORDER BY date desc");
$rows = mysql_num_rows($menu);
if(mysql_num_rows($menu)>0)
{
for($i=0; $i<mysql_num_rows($menu); $i++)
{
$result = mysql_fetch_object($menu);
echo("<table><tr><td><tc>$result->date @ $result->author</tc></td></tr><tr><td><tc>------------------</tc></td></tr><tr><td><tc>$result->text</tc></td></tr><tr><td><tc>------------------</tc></td></tr></table><br>");
}
}
}
}
?>
<head>