<?
$content .= "<div class=\"paginatie\">";
$content .= $paginatie;
$content .= "</div>";
$content .= "<div class=\"sterge\"> </div>";
$content .= "\n<h1>Skriv i gæstebogen</h1>";
$content .= "\n<form action=\"whatsup.php?page=guestbook&act=add\" method=\"post\">";
$content .= "\n<dl class=\"formular\">";
$content .= "<p>Navn</p><p><input type=\"text\" name=\"name\" value=\"".(!empty($_POST['name']) ? $_POST['name']: "")."\" /> *</p>";
$content .= "<p>E-mail</p><p><input type=\"text\" name=\"email\" value=\"".(!empty($_POST['email']) ? $_POST['email']: "")."\" /></p>";
$content .= "<p>URL</p><p><input type=\"text\" name=\"url\" value=\"".(!empty($_POST['url']) ? $_POST['url']: "
http://")."\" /></p>";
$content .= "<p>Kommentar</pt><p><textarea name=\"comments\" rows=\"5\" cols=\"40\">".(!empty($_POST['comments']) ? $_POST['comments']: "")."</textarea> *</p>";
$content .= "<p> </p><p><input type=\"submit\" value=\"Submit\" /></p>";
$content .= "\n</dl></form>";
include_once("admin/inc/connect.php");
$query = mysql_query("SELECT * FROM guestbook ORDER BY id DESC") or die(mysql_error());
$content = "";
$content .= "<div class=\"content\">";
$paginatie = "";
if ($_SERVER['REQUEST_METHOD']=='POST'){
if (!$_POST['name'] OR !$_POST['comments']) {
$content .= "<script>alert('Udfyld alle felter med *')</script>";
} else {
$date = time();
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$url = stripslashes($_POST['url']);
$comments = stripslashes($_POST['comments']);
$query = mysql_query("INSERT
INTO
guestbook
VALUES(
'NULL',
'".$date."',
'".$name."',
'".$email."',
'".$url."',
'".$comments."'
)
") or die(mysql_error());
echo "<script>document.location.replace('whatsup.php')</script>";
}
}
if (mysql_num_rows($query) > 0 ){
//create pages
$pg = empty($_GET['pg']) ? 1 : $_GET['pg'];
$catePePag = "10"; // no of items per page
$nrIntrari = mysql_num_rows($query);
$rest = ($nrIntrari % $catePePag);
$nrPag = IntVal($nrIntrari / $catePePag);
$paginatie = "Side: ";
if ($rest <> 0)
$nrPag = $nrPag + 1;
for ($i=1; $i<=$nrPag; $i++) {
if ($i == $pg)
$paginatie .=" <p>".$i."</p> ";
else
$paginatie .= "<a href=\"whatsup.php?&pg=".$i."\">".$i."</a> ";
}
if ((!intval($pg)) or ($pg > $nrPag))
echo "<script>location.href('whatsup.php?&pg=1');</script>";
$content .= "\n<b>Gæstebog Indlæg</b>";
$content .= "<div class=\"paginatie\">";
$content .= $paginatie;
$content .= "</div>";
if ($pg == 1)
$inf = 0;
else
$inf = $catePePag * ($pg-1);
$intrariPag = mysql_query("SELECT * FROM guestbook ORDER BY id DESC LIMIT " . $inf . ",". $catePePag. "") or die(mysql_error());
//end of pagination
for($i=0; $i<mysql_num_rows($intrariPag); $i++) {
$content .= "\n<dl class=\"formular\">";
$content .= "<p><i>Navn:</i></p><p>".mysql_result($intrariPag,$i,'name')."</p>";
if (mysql_result($intrariPag,$i,'email'))
$content .= "<p><i>E-mail:</i></p><p><a href=\"mailto:".mysql_result($intrariPag,$i,'email')."\">".mysql_result($intrariPag,$i,'email')."</a></p>";
if (mysql_result($intrariPag,$i,'url') != "
http://")
$content .= "<p><i>URL:</i></p><p><a href=\"".mysql_result($intrariPag,$i,'url')."\" target=\"_blank\">".mysql_result($intrariPag,$i,'url')."</a></p>";
$content .= "<p><i>Kommentar:</i></p><p>".mysql_result($intrariPag,$i,'comments')."</p>";
$content .= "\n</dl>";
$content .= "<div class=\"sterge\"> </div>";
if ($i != mysql_num_rows($intrariPag)-1)
$content .= "<hr />";
else
$content .= "<p style=\"margin: 4px 0; padding: 0;\"> </p>";
}
}
else {
$content .= "\n<h1>Gæstebog Indlæg</h1>";
$content .= "\n<p>Der er ikke blevet skrevet i gæstebogen endnu!</p>";
}
$content .= "<p style=\"font-size: 10px;\">Gæstebog v1.0 · © 2005 Peter Faarup</p>";
$content .= "</div>";
print $content;
?>