ich habe mir ein eigenes Gästebuch geschrieben, das funktioniert auch, nur sporadisch schreibt das Skript "array" in das url-Feld in die Datenbank und ich habe keine Ahnung warum, oder wo das Skript überhaupt ein Array herbekommen will.
Vielleicht sieht ja einer von euch den Fehler.
Code: Alles auswählen
<span class="ueberschrift">Gästebuch</span>
<br><br>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<table width="100%" border="0" cellPadding="2" cellSpacing="0" align="center">
<tr>
<td align="center">
<input type="button" class="button" name="eintragen" value="eintragen" onClick="self.location.href='<?php echo $PHP_SELF; ?>?eintragen=true'" style="width: 200px; background: #4A60A9;">
<input type="button" class="button" name="zurueck" value="ansehen" onClick="self.location.href='<?php echo $PHP_SELF; ?>'" style="width: 200px; background: #4A60A9;">
<br><br>
</td>
</tr>
<tr>
<td>
<!-- Beginn Gästebuch -->
<?php
function formular($name, $email, $url, $text) {
?>
<table border="0" cellpadding="0" cellspacing="0">
<tr valign="top">
<td>Mein Name: </td>
<td><input name="name" size="10" class="formular"<?php if ($name != "") { echo " value='". $name ."'"; } ?>></td>
</tr>
<tr valign="top">
<td>Meine eMail-Adresse: </td>
<td><input name="email" size="10" class="formular"<?php if ($email != "") { echo " value='". $email ."'"; } ?>></td>
</tr>
<tr valign="top">
<td>Meine Homepage: </td>
<td>http://<input name="url" size="10" class="formular" style="width: 312px;"<?php if ($url != "") { echo " value='". $url ."'"; } ?>></td>
</tr>
<tr valign="top">
<td>Meine Nachricht: </td>
<td><textarea cols="15" rows="10" name="text" wrap="soft" class="formular"><?php if ($text != "") { echo $text; } ?></textarea></td>
</tr>
<tr valign="top">
<td><br>Und noch hier drücken: </td>
<td><br><input type="submit" name="senden" value="Und weg damit!" width="10" class="formular"> </td>
</tr>
</table>
<?php
}
if (isset($senden)) {
$name = stripslashes(htmlentities(strip_tags($name), ENT_QUOTES));
$email = stripslashes(htmlentities(strtolower(strip_tags($email)), ENT_QUOTES));
$url = stripslashes(htmlentities(strtolower(strip_tags($url)), ENT_QUOTES));
$url = str_replace("http://", "", $url);
$text = stripslashes(htmlentities(strip_tags($text), ENT_QUOTES));
$ip = getenv("REMOTE_ADDR");
$host = gethostbyaddr($ip);
$browser = getenv("HTTP_USER_AGENT");
$fehler = "";
if ($name == "") { $fehler .= "<li>deinen <a>Namen</a></li>"; }
if ($email == "") { $fehler .= "<li>deine <a>eMail-Adresse</a></li>"; }
else {
if (preg_match("/^([_a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$/", $email, $regs))
{ ; }
else {
$fehler .= "<li><a>eine gültige eMail-Adresse</a></li>";
}
if ($text == "") { $fehler .= "<li>den <a>Text</a></li>"; }
}
if ($fehler != "") {
?>
<div class="wo"><b>Toll! Ein Fehler!</b></div><br>
<b>Du Lümmel!</b> Folgende Angaben wolltest du uns schlichtweg unterschlagen:
<ul>
<?php
echo $fehler;
?></ul>
Also geh' deiner Pflicht nach und füll' das Formular vollständig aus. Sonst
ist Schluss mit lustig.<br><br>
<?php
echo formular($name, $email, $url, $text);
}
else {
$text = nl2br($text);
$datum = date("Y-m-d");
$zeit = date("H:i:s");
$strGBookEntry = "INSERT INTO sc_gbook (id, name, email, url, text, datum, zeit, ip, host, browser) ".
"VALUES ('', '".
$name ."', '".
$email ."', '".
$url ."', '".
$text ."', '".
$datum ."', '".
$zeit ."', '".
$ip ."', '".
$host ."', '".
$browser ."')";
$sqlGBookEntry = mysql_query($strGBookEntry);
?>
Herzlichen Glückwunsch! Du hast dich nun in unserem Gästebuch verewigt. Wenn du diesen
netten Link anklickst, kannst du dir dein Gesülze gleich <a href="<?php echo $PHP_SELF; ?>">ansehen</a>.
<META HTTP-EQUIV="REFRESH" CONTENT="3; URL=<?php echo $PHP_SELF; ?>">
<?php
}
}
elseif (isset($eintragen)) {
echo formular($name,$email,$homepage,$url,$text);
}
else {
$Zeilen_pro_Seite = 10;
if (!isset($lp)) {
$lp = 0;
}
$Anzahl = mysql_num_rows(mysql_query("SELECT * FROM sc_gbook"));
$strGBook = "SELECT * FROM sc_gbook ORDER BY datum DESC, zeit DESC LIMIT ". $lp .", ". $Zeilen_pro_Seite ."";
$sqlGBook = mysql_query($strGBook);
while ($rowGBook = mysql_fetch_array($sqlGBook)) {
$rowDatum = explode("-", $rowGBook["datum"]);
$printDatum = date("d.m.Y", mktime(0,0,0,$rowDatum[1],$rowDatum[2],$rowDatum[0]));
$rowZeit = explode(":", $rowGBook["zeit"]);
$printZeit = $rowZeit[0] .":". $rowZeit[1] ." Uhr";
?>
<!-- Tabelle zum zentrieren -->
<table border="0" width="100%" cellSpacing="0" cellPadding="0">
<tr>
<td width="15%"> </td>
<td width="*" align="center">
<!-- Gästebucheinträge -->
<table border="0" class="gb" cellSpacing="2" cellPadding="3" style="table-layout: fixed;">
<tr>
<td style="width: 100px; text-align:right"><b>Name:</b></td>
<td style="width: 450px; background-color: #4A60A9; color: #FFFFFF;"><?php echo $rowGBook["name"]; ?></td>
</tr>
<tr>
<td style="width: 100px; text-align:right"><b>Datum:</b></td>
<td style="width: 450px; background-color: #4A60A9; color: #FFFFFF;"><?php echo $printDatum; ?></td>
</tr>
<tr>
<td style="width: 100px; text-align:right"><b>Zeit:</b></td>
<td style="width: 450px; background-color: #4A60A9; color: #FFFFFF;"><?php echo $printZeit; ?></td>
</tr>
<tr>
<td style="width: 100px; text-align:right"><b>eMail:</b></td>
<td style="width: 450px; background-color: #4A60A9;"><a href="mailto:<?php echo $rowGBook["email"]; ?>" style="font: #FFFFFF; color: #FFFFFF;"><?php echo $rowGBook["email"]; ?></a></td>
</tr>
<?php if ($rowGBook["url"] != "") { ?>
<tr>
<td style="width: 100px; text-align:right"><b>Homepage:</b></td>
<td style="width: 450px; background-color: #4A60A9;"><a href="http://<?php echo $rowGBook["url"]; ?>" target="_blank" style="color: #FFFFFF;">http://<?php echo $rowGBook["url"]; ?></a></td>
</tr>
<?php } ?>
<tr>
<td style="width: 100px; text-align:right; vertical-align: top"><b>Text:</b></td>
<td style="width: 450px; background-color: #4A60A9; color: #FFFFFF;"><?php echo $rowGBook["text"]; ?></td>
</tr>
<?php if ($rowGBook["kommentar"] != "") { ?>
<tr>
<td style="width: 100px; text-align:right; vertical-align: top"><b>Kommentar:</b></td>
<td style="width: 400px; background-color: #1E90FF; color: #FFFFFF;"><?php echo $rowGBook["kommentar"]; ?></td>
</tr>
<?php } ?>
</table>
<!-- Ende Gästebucheinträge -->
</td>
<td width="15%"> </td>
</tr>
</table>
<!-- Ende Tabelle zum zentrieren -->
<br>
<?php
}
if ($lp > 0) {
echo "<a href='". $PHP_SELF ."?lp=0'>erste Seite</a> ";
$back = $lp - $Zeilen_pro_Seite;
if ($back < 0) {
$back = 0;
}
echo "<a href='". $PHP_SELF ."?lp=". $back ."' style='text-decoration: none;'>«</a> ";
}
if ($Anzahl > $Zeilen_pro_Seite) {
$Seiten = intval($Anzahl / $Zeilen_pro_Seite);
if ($Anzahl % $Zeilen_pro_Seite) {
$Seiten++;
}
}
for ($i = 1; $i <= $Seiten; $i++) {
$fwd = ($i - 1) * $Zeilen_pro_Seite;
echo "<a href='". $PHP_SELF ."?lp=". $fwd ."'>". $i ."</a> ";
$lastPage = $fwd;
}
if ($lp < $Anzahl - $Zeilen_pro_Seite) {
$fwd = $lp + $Zeilen_pro_Seite;
echo "<a href='". $PHP_SELF ."?lp=". $fwd ."' style='text-decoration: none;'>»</a> ";
$fwd = $Anzahl - $Zeilen_pro_Seite;
echo "<a href='". $PHP_SELF ."?lp=". $lastPage ."'>letzte Seite</a>";
}
}
?>
<!-- Ende Gästebuch -->
</td>
</tr>
</table>
</form>
Die zugehörige Datenbank Tabelle sieht wie folgt aus:
[ externes Bild ]
Danke im vorraus
Xmopf