Christoph Burghardt

 Start   

Gästebuch


tabelleanlegen.php


<?php
include ('config2.php');
$a= mysql_query("create table gaestebuch (
id int (10) not null auto_increment,
name text not null,
email varchar (70) not null default ' ',
homepage varchar (70) not null default ' ',
ueberschrift text not null,
kommentar text not null,
bewertung varchar (20) not null default ' ',
freigabe varchar (10) not null default '0',
datum varchar (250) not null default ' ',
primary key (id)
) type=myisam; ");

?>


config2.php

<?php
$server= "localhost";
$user= "root";
$passwort= "root";
$datenbank= "xy";
$verbindung= mysql_connect ($server, $user, $passwort) or die ("Es konnte keine
Verbindung zum Server hergestellt werden.");
mysql_select_db ($datenbank) or die ("Die Datenbank existiert nicht.");

?>


time.php

<?php
$timestamp= time();
//$timestamp= $timestamp -3600; // Sommerzeit
$date1= date("d.m.y", $timestamp);
$time1= date("H:i", $timestamp);

?>


index.php

<html>
<head>
<title>
Gästebuch
</title>
</head>

<body>

<div align="center">

<h2> Tragen Sie sich in das Gästebuch ein </h2>

<form action="eintragen.php" method="get">

<table width="350" cellspacing="5">

<tr>

<td>

Ihr Name

</td>

<td>

<input type="text" name="name" class="eing" >

</td>

</tr>

<tr>

<td>

Ihre Email

</td>

<td>

<input type="text" name="email" class="eing" >

</td>

</tr>

<tr>

<td>

Ihre Homepage

</td>

<td>

<input type="text" name="homepage" value="http://" class="eing" >

</td>

</tr>

<tr>

<td>

Überschrift

</td>

<td>

<input type="text" name="ueberschrift" class="eing" >

</td>

</tr>

<tr>

<td>

Kommentar

</td>

<td>

<textarea name="kommentar" class="eing"

cols="15" rows="5" >

</textarea>

</td>

</tr>

<tr>

<td valign="top">

<br>

Wie finden Sie unsere Seiten?

</td>

</tr>

<tr>

<td align="right">

gut

<input type="radio" name="bewertung" value="gut">

</td>

</tr>

<tr>

<td align="right">

mittel

<input type="radio" name="bewertung" value="mittel"
checked="checked" >

</td>

</tr>

<tr>

<td align="right">

schlecht

<input type="radio" name="bewertung" value="schlecht">

</td>

</tr>

<tr>

<td align="center">

<br>

<br>

<input type="reset" value="reset" class="sender">

<input type="submit" value="submit" class="sender">

<?php
include ('time.php');

?>

<input name="date" type="hidden" value="

<?php

echo "$date1, $time1";

?>" >

</td>

</tr>

</table>

</form>


<hr> <h3> Bisherige Einträge </h3>

<table width="350" cellspacing="5">

<tr>

<td>

<?php
include('config2.php');
$a= mysql_query("select * from gaestebuch where freigabe = 'ja' order by id
desc ");

while ($row= mysql_fetch_row($a))

{

echo $row[0];
echo '<br>';
echo $row[1];
echo '<br>';
echo $row[2];
echo '<br>';
echo $row[3];
echo '<br>';
echo $row[4];
echo '<br>';
echo $row[5];
echo '<br>';
echo $row[6];
echo '<br>';
echo $row[7];
echo '<br>';
echo $row[8];
echo '<br>';
echo $row[9];
echo '<br>';
echo $row[10];
echo '<br>';

}

?>

</td>

</table>

</div>

</body>

</html>


eintragen.php

<?php
$name= $_GET["name"];
$email= $_GET["email"];
$homepage= $_GET["homepage"];
$ueberschrift= $_GET["ueberschrift"];
$kommentar= $_GET["kommentar"];
$bewertung= $_GET["bewertung"];
$freigabe= $_GET["freigabe"];
$date= $_GET["date"];

$freigabe= "nein";

include('config2.php');

$a="insert into gaestebuch (name, email, homepage, ueberschrift, kommentar, bewertung, freigabe, datum)

values ('$name', '$email', '$homepage', '$ueberschrift', '$kommentar', '$bewertung', '$freigabe', '$date')";

$b= mysql_query($a);

?>

<html>

<body>

<h2>

Vielen Dank, der Eintrag erfolgt später

<a href = "http://localhost/gaestebuch/index.php"> zurück zum Gästebuch

</a>

</h2>

</body>

</html>


admi.php

<?php
include('config2.php');
$result=mysql_query("select * from gaestebuch where freigabe !='ja' ");
$menge=mysql_num_rows($result);
while($row=mysql_fetch_row($result))

{

echo $row[0];
echo '<br>';
echo $row[1];
echo '<br>';
echo $row[2];
echo '<br>';
echo $row[3];
echo '<br>';
echo $row[4];
echo '<br>';
echo $row[5];
echo '<br>';
echo $row[6];
echo '<br>';
echo $row[7];
echo '<br>';
echo $row[8];
echo '<br>';
echo $row[9];
echo '<br>';

?>

<form action="loeschen.php?id=

<?php
echo $row[0];

?>

method="get">

<input type="submit" value="delete">
<input type="hidden" name="id" value="<?php echo $row[0]; ?> " >

</form>

<form action="freigabe.php?id= <?php echo $row[0]; ?>

method="get">
<input type="submit" value="freigeben">
<input type="hidden" name="id" value="<?php echo $row[0]; ?> " >

</form>

<?php

}

?>

freigabe.php

<?php
include('config2.php');
$id=$_GET['id'];
$a="update gaestebuch set freigabe ='ja' where id= '$id' ";
$b=mysql_query($a);

?>


loeschen.php

<?php
include('config2.php');
$id=$_GET['id'];
$a="delete from gaestebuch where id= '$id'";
$b=mysql_query($a);

?>


Tragen Sie sich in das Gästebuch ein

Ihr Name
Ihre Email
Ihre Homepage
Überschrift
Kommentar

Wie finden Sie unsere Seiten?
gut
mittel
schlecht



Bisherige Einträge

5
Christoph Burghardt
ch.burghardt@googlemail.com
http://www.christoph-burghardt.com
Test
Test
mittel
ja
13.01.08, 23:00


Valid HTML 4.01 Transitional