<?php
$id = "username";
$pw = "password";
$host ="localhost";
$database = "databsename";
$table = "gbook";
$conn_id = mysql_connect($host,$id,$pw);
mysql_select_db($database,$conn_id);
$action = $HTTP_GET_VARS["action"];
if($action=="save")
{
$content = "Der Besucher".$name." hat gerade einen Eintrag in Ihr Gästebuch vorgenommen!";
$an = "e@mail.de";
$betreff = "gaestebucheintrag";
@mail($an,$betreff,$content,"From: ".$email);
$datum = time();
$inhalt = $inhalt;
$name = ($name) ? $name : "unbekannt";
mysql_query("INSERT INTO $table (name,email,hp,inhalt,datum) VALUES ('$name','$email','$hp','$inhalt','$datum')");
}
echo "<td width=75% height=100% align=center valign=top>";
if($action=="neu")
{
echo "<a href='index.php?page=Guestbook'>Gästebuch<p></a>";
}
else
{
echo "<p><a href='".$HTTP_SERVER_VARS[PHP_SELF]."?action=neu&page=Guestbook'>Eintragen<p></a>";
}
if($action=="neu")
{
?>
<style type="text/css">
<!--
.Stil3 {font-family: Arial, Helvetica, sans-serif; color: #000000; }
-->
</style>
<table>
<form action="<?php echo '".$HTTP_SERVER_VARS[PHP_SELF]."?action=save&page=Guestbook'; ?>" method=get>
<tr>
<input type="hidden" name="action" value="save">
<td><span class="Stil3">Name:</span></td>
<td><input name=name type=text></td>
</tr>
<tr>
<td><span class="Stil3">Email:</span></td>
<td><input name=email type=TEXT></td>
</tr>
<tr>
<td><span class="Stil3">Homepage: http://</span></td>
<td><input name=hp type=text></td>
</tr>
<tr>
<td><span class="Stil3">Eintrag:</span></td>
<td><span class="Stil3">
<textarea name="inhalt" rows="6" cols="25"></textarea>
</span></td>
</tr>
<tr>
<td> </td>
<td><input type=submit value="eintragen"></td>
</form>
</tr>
</table>
<?php
}
else
{
$query = "SELECT * FROM $table ORDER BY datum DESC LIMIT 0,50";
$result = mysql_query($query);
if(mysql_num_rows($result))
{
while($row=mysql_fetch_array($result))
{
$name = $row['name'];
$email = $row['email'];
$hp = $row['hp'];
$inhalt = $row['inhalt'];
$datum = date("d.m.Y/H:i:s",$row['datum']);
echo "<table width='90%' valign='top' align='center'><tr><td width='75%' align='left'><b><a href=mailto:".$email.">".$name."</a></b></td><td align='right'>".$datum."</td></tr></table>";
$inhalt = nl2br($inhalt);
echo "<table width='90%' align='center'><tr><td colspan='2'>".$inhalt;
echo "</td></tr></table>";
if($hp=="")
{
echo "<tr><td></td></tr></table><p>";
}
else
{
echo "<table width='90%' align='center'><tr><td width='95%'><a href='http://".$hp."' target='new'>".$hp."</a></td><td align=center><a href='#top'>top</a></td></tr></table><p>";
}
flush();
}
}
else
{
echo "<b>Es sind noch keine Eiträge vorhanden!</b>";
}
}
if($action==neu)
{
echo "<a href='".$HTTP_SERVER_VARS[PHP_SELF]."?page=Guestbook'><p>Gästebuch</a>";
}
else
{
echo "<p><a href='".$HTTP_SERVER_VARS[PHP_SELF]."?action=neu&page=Guestbook'>Eintragen</a>";
}
?>