ok ich hab da was für dich...also erstell diese dateien:
- gb.php
- gb.txt
- gb_add.php
- gb_leer.php
- gb_new.php
dann fangen wir mit der gb.php an:
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" height="10">
<?
$datei="gb.txt";
$inhalt = file($datei,"r");
$anzahl = count($inhalt);
?>
[url='gb_new.php']Neuer Eintrag [/url]-
<?php echo "$anzahl";?>
Einträge
<hr width="90%">
<?
$datei="gb.txt";
{
$inhalt = file($datei,"r");
$anzahl = count($inhalt);
for($i = 0; $i < $anzahl; $i++)
{
$newinhalt = array_reverse($inhalt);
$eintrag = explode("|-|",$newinhalt[$i]);
$name = $eintrag[0];
$email = $eintrag[1];
$homepage = $eintrag[2];
$text = $eintrag[3];
$datum = $eintrag[4];
$uhrzeit = $eintrag[5];
?>
<table width="90%" border="0" align="center" >
<tr>
<td width="50%" style="border-left-style: solid; border-left-width: 1; border-top-style: solid; border-top-width: 1" bgcolor="#FFFFFF" bordercolor="#000000">
<font color="#000000">Name:</font>
<font color="#000000"><?php echo "$name"; ?></font>
</font>
</td>
<td width="50%" style="border-right-style: solid; border-right-width: 1; border-top-style: solid; border-top-width: 1" bgcolor="#FFFFFF" bordercolor="#000000">
<font color="#000000">Homepage: </font>
[url='<?php'] target="_blank"><?php echo "$homepage"; ?>[/url]
</td>
</tr>
<tr>
<td width="50%" style="border-left-style: solid; border-left-width: 1; border-bottom-style: solid; border-bottom-width: 1" bgcolor="#FFFFFF" bordercolor="#000000">
<font color="#000000">email: </font>
[url='<?php']> <?php echo "$email"; ?>[/url]
</td>
<td width="50%" style="border-right-style: solid; border-right-width: 1; border-bottom-style: solid; border-bottom-width: 1" bgcolor="#FFFFFF" bordercolor="#000000">
<font color="#000000">Datum/Uhrzeit: </font> <font color="#000000">
<?php echo "$datum"; ?>
-
<?php echo "$uhrzeit"; ?>
</font>
</td>
</tr>
</table>
<table width="90%" border="1" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
<tr>
<td width="30" style="border-style: solid; border-width: 1" bgcolor="#FFFFFF">
<font color="#000000">Text:</font></td>
<td bgcolor="#FFFFFF" bordercolor="#000000" style="border-top-color: #111111; border-top-width: 1; border-bottom-color: #111111; border-bottom-width: 1">
<font color="#000000"><?php echo "$text"; ?></font>
</td>
</tr>
</table>
<font color="#000000">
</font>
<?
}
}
?>
</td>
</tr>
</table>
Alles anzeigen
deine gb.txt bleibt leer und in eine gb_add.php kommt rein:
<?php
if ($name == "" || $text == "")
{
echo "<meta http-equiv=\"refresh\" content=\"0; URL=gb_leer.php\">";
}
else
{
if ($homepage == "http://")
{
$homepage = "";
}
$datum = date("d.m.Y");
$uhrzeit = date("H:i:s");
$datei = fopen("gb.txt","a+");
$newBericht = str_replace("\r","
",$text);
$Bericht = str_replace("\n","
",$newBericht);
fwrite($datei, "$name|-|$email|-|$homepage|-|$Bericht|-|$datum|-|$uhrzeit|-|\n");
fclose($datei);
echo "<meta http-equiv=\"refresh\" content=\"0; URL=gb.php\">";
mail("deinemail@deinhost.xx", "Gästebuch", "Neuer Eintrag:\n\nZeit: $datum - $uhrzeit Uhr\nVon: $name\nEmail:$email\n\nText:$text");
}
?>
Alles anzeigen
bei deinemail@deinhost.xx gibste deine e-mail an, dann wirst du be jedem beitrag informiert...
dann schreibst du in deine gb_leer.php
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" height="417">Du hast die Felder Name und/oder
Text leer gelassen, diese müssen ausgefüllt werden!
M öchtest du es nochmal probieren, dann klicke
[url='javascript:history.back()']hier! [/url]
</td>
</tr>
</table>
Alles anzeigen
Die seite wird aufgerufen wenn name oder das kommentar feld freigelassen wird.
Und in deine gb_new.php schreibste rein:
<table width="376" cellpadding="0" cellspacing="0">
<tr>
<td align="center" height="417" width="376">
<form method="POST" action="gb_add.php">
<table>
<tr>
<td>Name</td>
<td>
<input type="text" name="name" size="22">
</td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" name="email" size="22">
</td>
</tr>
<tr>
<td>Homepage</td>
<td>
<input type="text" name="homepage" size="22" value="http://">
</td>
</tr>
<tr>
<td>Text</td>
<td>
<textarea rows="6" name="text" cols="30"></textarea>
</td>
</tr>
</table>
<input class="button" type="reset" name="reset2" value="Inhalt löschen" />
<input type="submit" value="Abschicken" name="Senden">
</p>
</form>
[url='gb.php']zurück zum Gästebuch[/url]
</td>
</tr>
</table>
Alles anzeigen
dann hast ein gästebuch ohne sql, aber es muss php auf deinem webserver verfügbar sein..
greetz mülla