PHP:
function guestbook()
{
if($action == "eintragen"){
$text = str_replace("/n","<br>",$text);
$sql ="INSERT INTO guestbook (name, email, hp, date, text) ";
$sql .="VALUES ";
$sql .="('$name', '$email', '$hp', '$date', '$text')";
$result = mysql_query($sql);
if($result){
echo "<center>The entry was insert into the Database.<br><a href=\"guestbook.php\">Back to guestbook</a></center>";
}
else{
echo "<center>".mysql_error($result)."</center>";
}
}
else{
echo "<br><h3><font face=\"Verdana\">Guestbook</font></h3><br>
<form action=\"guestbook.php?action=eintragen\" method=\"POST\">
<table width=\"55%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" border=\"1\" bordercolor=\"#000000\">
<tr>
<td>
<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
<tr>
<td class=\"normaltext\">Name</td><td><input type=\"text\" name=\"name\" size=\"30\"></td>
</tr>
<tr>
<td class=\"normaltext\">E-mail</td><td><input type=\"text\" name=\"email\" size=\"30\"></td>
</tr>
<tr>
<td class=\"normaltext\">Homepage</td><td><input type=\"text\" name=\"hp\" size=\"30\"></td>
</tr>
</table>
</td>
<td>
<textarea rows=\"5\" cols=\"35\" name=\"text\"></textarea>
</td>
</tr>
<tr>
<td class=\"normaltext\" colspan=\"2\" align=\"center\"><input type=\"Submit\" value=\"Send\"> <input type=\"Reset\" value=\"Reset\"></td>
</tr>
</table>
<input type=\"hidden\" name=\"date\" value=\"".date("j. F y")."\">
</form>";
$gbaction = mysql_query("SELECT * FROM guestbook ORDER BY id");
while($gb = mysql_fetch_array($gbaction)){
echo "<table width=\"55%\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" border=\"1\" bordercolor=\"#000000\">
<tr>
<td class=\"headline\" bgcolor=\"#336699\" align=\"center\">".$gb['date']." - <a href=\"mailto:".$gb['email']."\">".$gb['name']."</a> <a href=\"".$gb['hp']."\" target=\"_blank\">".$gb['hp']."</a></td>
</tr>
<tr class=\"normaltext\">
<td class=\"normaltext\">
".$gb['text']."</td></tr>
</table>";
}
}
}
Warum geht es nicht, wenn ich auf submit drücke kommt gleich wieder das Eingabeformular... Langsam bin ich verzweifelt...