Gästebuch Hilfe!

vintage1

Grünschnabel
Hallo,
hab jetzt meine Seite endlich online.
Bin bei all-inkl.com, hab auch php und mysql dabei.
Ich möchte eigentlich nur ein einfaches Gästebuch haben.
Hab heut den ganzen Tag schon mit irgendwelchen Tutorials rumgemacht, aber keins hat funktioniert, oder ich habs falsch gemacht.
Bitte gibt mir doch mal Hilfe, wie ich eins erstellen kann, mit einer .txt datei z.b.
Danke.
 
Wenn du eine konkrete Frage hast, dann wird dir bestimmt geholfen. Aber ich glaube nicht, dass dir jetzt hier jemand den Code für ein GB vorkaut. Zumal es hier auf tutorials.de schon ein Tutorial zum Thema Gästebuch gibt, siehe hier!

Mfg Mau
 
hi,

es gibt auf tutorials.de mehrere Gästebücher-Tutorials. Ich hab eins gefunden, das mit MySQL läuft. Da du ja sagtest, dss du nen provider hast, der MySQL unterstützt, schlag ich dir mal das vor:

PHP:
<?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>"; //die ausgabe der daten 
   $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>"; 
} 
?>

Der code wurde scon ein paar mal überarbeitet. Es funkt auch, nur wenn man sich einträgt, und im gästebuch dann auf aktualisieren klickt, wird der selbe eintrag erneut eingetragen. Aber ich hab grad nen neuen Thread geöffnet, und fanste hat auch schon geholfen, nur weiß ich nicht so, wie man das anwenden soll.

mfg,

fabi
 
Zurück