Wäre jemand so gütig und würde mir die Codes so umschreiben, dass ich das Gästebuch in dem Ordner gästebuch hochladen könnte?
Wenn ihr Lust habt:
admin.php:
book.php:
config.inc.php:
worte.php:
form.php:
entry.php:
gbook.php:
delete.php:
wäre sehr hilfreich, weil ich es selber nicht hinbekomme.
mfg El_Tomato
Wenn ihr Lust habt:
admin.php:
PHP:
<?php
if($adminpass == $_POST['passwd'])
{
include("config.inc.php");
$sql = "SELECT * FROM `gbook` ORDER BY `datum` DESC";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result))
{
$avMail = avMail($row->email);
$avPage = avPage($row->website);
$text = $row->text;
$text = ereg_replace("\n", "<br />", $text);
$text = ereg_replace("\\[URL \]http://([^ ]*)\[/URL\]", "<a href=\"http://\\1\" target=\"_blank\">\\1</a>", $text);
$text = ereg_replace("\\[URL \]([^ ]*)\[/URL\]", "<a href=\"http://\\1\" target=\"_blank\">\\1</a>", $text);
$text = ereg_replace("\\[B \]([^ ]*)\[/B\]", "<b>\\1</b>", $text);
$text = ereg_replace("\\[I \]([^ ]*)\[/I\]", "<i>\\1</i>", $text);
$text = ereg_replace("\\[U \]([^ ]*)\[/U\]", "<u>\\1</u>", $text);
$text = ereg_replace("\\[IMG \]([^ ]*)\[/IMG\]", "<img src=\"\\1\" border=\"0\" style=\"border: 0px;\">", $text);
if(file_exists("worte.php")){
include("worte.php");}
echo("
<script language=\"JavaScript\">
function janein ()
{
zeigen=confirm(\"Möchtest Du diesen Eintrag wirklich löschen?\");
if(zeigen==true)
{
document.location.href=\"delete.php?id=".$row->id."\";
}
else
{
document.location.href=\"#\";
}
}
</script>
<table width=\"100%\">
<tr>
<td width=\"30%\"> </td>
<td width=\"70%\">Geschrieben von <b>".$row->name."</b> am <b>".$row->datum."</b></td>
</tr>
<tr>
<td width=\"30%\" valign=\"top\"><b>".$row->name."</b><br />".$avPage." ".$avMail."</td>
<td width=\"70%\" valign=\"top\">".$text."</td>
</tr>
<tr>
<td><input type=\"button\" onclick=\"javascript:janein();\" value=\"löschen\"></td>
<td></td>
</tr>
</table>
<table border=\"0\" width=\"100%\" style=\"border-bottom-width: 118:32:03px\">
<tr>
<td style=\"border-bottom-style: dotted; border-bottom-width: 1px;\"> </td>
</tr>
</table>
");
}
}
else
{
echo("
<form action=\"$_SERVER['PHP_SELF']\" method=\"post\">
<input name=\"passwd\" type=\"password\"><br>
<input type=\"submit\" value=\"Login\" />
</form>
")
}
?>
book.php:
PHP:
<?php
echo("<a href=\"?action=form\">eintragen</a>");
$sql = "SELECT * FROM `gbook` ORDER BY `datum` DESC";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result))
{
$avMail = avMail($row->email);
$avPage = avPage($row->website);
$text = $row->text;
$text = ereg_replace("\n", "<br />", $text);
$text = ereg_replace("\\[URL \]http://([^ ]*)\\[/URL\]", "<a href=\"http://\\1\" target=\"_blank\">\\1</a>", $text);
$text = ereg_replace("\\[URL \]([^ ]*)\\[/URL\]", "<a href=\"http://\\1\" target=\"_blank\">\\1</a>", $text);
$text = ereg_replace("\\[B \]([^ ]*)\\[/B\]", "<b>\\1</b>", $text);
$text = ereg_replace("\\[I \]([^ ]*)\\[/I\]", "<i>\\1</i>", $text);
$text = ereg_replace("\\[U \]([^ ]*)\\[/U\]", "<u>\\1</u>", $text);
$text = ereg_replace("\\[IMG \]([^ ]*)\\[/IMG\]", "<img src=\"\\1\" border=\"0\" style=\"border: 0px;\">", $text);
if(file_exists("worte.php")){
include("worte.php");}
echo("
<table width=\"100%\">
<tr>
<td width=\"30%\"> </td>
<td width=\"70%\">Geschrieben von <b>".$row->name."</b> am <b>".$row->datum."</b></td>
</tr>
<tr>
<td width=\"30%\" valign=\"top\"><b>".$row->name."</b><br />".$avPage." ".$avMail."</td>
<td width=\"70%\" valign=\"top\">".$text."</td>
</tr>
</table>
<table border=\"0\" width=\"100%\" style=\"border-bottom-width: 118:32:03px\">
<tr>
<td style=\"border-bottom-style: dotted; border-bottom-width: 1px;\"> </td>
</tr>
</table>
");
}
?>
config.inc.php:
PHP:
<?php
$adminpass = "ADMIN"; // passwort für den adminbereich
$dbhost = "localhost"; // host
$dbuser = "root"; // username
$dbpass = "pass"; // passwort
$dbselect = "db"; // datenbank
mysql_connect("$dbhost", "$dbuser", "$dbpass");
mysql_select_db("$dbselect");
function avMail($email)
{
if($email == "")
{
$avMail = "";
}
else
{
$avMail = "<a href=\"mailto:".$email."\">e-m@il</a>";
}
return $avMail;
}
function avPage($website)
{
if($website == "")
{
$avpage = "";
}
else
{
$avPage = "<a href=\"http://".$website."\">website</a>";
}
return $avPage;
}
?>
worte.php:
PHP:
<?php
$text = ereg_replace("WORT", "ERSETZUNG", $text);
?>
form.php:
PHP:
<form action="gbook.php?action=entry" method="post">
<table>
<tr>
<td><h1>Gästebuch</h1></td>
</tr>
<tr>
<td>Dein Name:</td>
<td><input name="entry_name"></td>
</tr>
<tr>
<td>Deine Email:</td>
<td><input name="entry_mail"></td>
</tr>
<tr>
<td>Deine Website:</td>
<td><input name="entry_page"> ohne <b>http://</b></td>
</tr>
<tr>
<td>Deine Nachricht:</td>
<td><textarea name="entry_text" rows="10" cols="50"></textarea></td>
</tr>
</table>
<table>
<tr>
<td><input type="submit" value="Eintragen" /></td>
</tr>
</table>
</form>
entry.php:
PHP:
<?php
$name = $_POST['entry_name'];
$email = $_POST['entry_mail'];
$website = $_POST['entry_page'];
$text = $_POST['entry_text'];
$zeit = time();
$time = date("Y-m-d H:i:s",$zeit);
$sql = "INSERT INTO `gbook`(`name`, `website`, `email`, `datum`, `text`) VALUES ('$name', '$website', '$email', '$time', '$text')";
$result = mysql_query($sql);
echo("<meta http-equiv=\"refresh\" content=\"0; url=?action=book\" />"); // leitet weiter zum Gästebuch!
?>
gbook.php:
PHP:
<?php
include("config.inc.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Gästebuch</title>
</head>
<body>
<?php
$url = array();
$url['book'] = "book.php";
$url['form'] = "form.php";
$url['entry'] = "entry.php";
if(isset($_GET['action']) AND isset($url[$_GET['action']]))
{
include $url[$_GET['action']];
}
else
{
include $url['book'];
}
?>
</body>
</html>
delete.php:
PHP:
<?php
include("config.inc.php");
$sql = "DELETE FROM `gbook` WHERE `id` = ".$_GET['id']."";
$result = mysql_query($sql) or die("Error");;
echo("<meta http-equiv=\"refresh\" content=\"0; url=admin.php\" />");
?>
wäre sehr hilfreich, weil ich es selber nicht hinbekomme.
mfg El_Tomato