wie erstelle ich z.b ein Gästebcuh ( xampp )

Alles, was PHP betrifft, kann hier besprochen werden.

wie erstelle ich z.b ein Gästebcuh ( xampp )

Postby apachetester » 20. October 2004 23:27

moin Leutz

Habe da mal ein Script entwickelt für ein gästebuch

Name der Datei INDEX.php
Code: Select all
<?php

error_reporting(0);

   include "mysql_connect.php";

   $res = mysql_db_query("$database_name",
          "select * from guestbook order by entry_id desc");
   $num = mysql_num_rows($res);

   ?>
   <hr color="black" size="1">
   <font face="Verdana" size="1">
   <a href="guestbook_new.php" style="text-decoration: none">&raquo; Neuer Eintrag</a> - <?php echo "$num Einträge"; ?>
   </font>
   <hr color="black" size="1">
   <?php

   for ($i=0; $i<$num; $i++)
   {
      $name = mysql_result($res, $i, "name");
      $email = mysql_result($res, $i, "email");
      $homepage = mysql_result($res, $i, "homepage");
      $text = mysql_result($res, $i, "text");
      $datum = mysql_result($res, $i, "datum");


      ?>
      <table>
      <tr><td><b><font face="Verdana" size="1">Name:</td><td width="175"><font face="Verdana" size="1"><?php echo "$name"; ?>
        </font></font></td><td><b>
        <font face="Verdana" size="1">EMail:</td><td><font face="Verdana" size="1"><?php echo "$email"; ?>
        </font></font></td></tr>
      <tr><td><b><font face="Verdana" size="1">Datum:</td><td width="175"><font face="Verdana" size="1"><?php echo "$datum"; ?>
        </font></font></td><td><b>
        <font face="Verdana" size="1">Homepage:</font></td><td>
        <font face="Verdana" size="1">
        <a style="text-decoration: none" href=<?php echo "$homepage"; ?> target="_blank"><?php echo "$homepage"; ?></a></font></td></tr>
      </table>

      <table>
      <tr><td><b><font face="Verdana" size="1">Eintrag:</font></td><td colspan="3"><font face="Verdana" size="1"><?php echo "$text"; ?>
      </font></td></tr>
      </table>

      <hr color="black" size="1">
      <?php

   }

   mysql_close($db);

?>


Name der Datei install.php
Code: Select all
<?php

include "mysql_connect.php";

$sqlab = 'CREATE TABLE `guestbook` ( `entry_id` INT NOT NULL AUTO_INCREMENT ,'
       . ' `name` TEXT NOT NULL ,'
       . ' `email` TEXT NOT NULL ,'
       . ' `homepage` TEXT NOT NULL ,'
       . ' `text` TEXT NOT NULL ,'
       . ' `datum` TEXT NOT NULL ,'
       . ' PRIMARY KEY ( `entry_id` ) );'
       . ' ';
       
mysql_db_query("$database_name", $sqlab);

echo "<b>Sofern die SQL-Daten richtig eingegeben wurden, sind jetzt alle Tabellen erstellt!</b>";

?>


Name der Datei mysql_connect.php
Code: Select all
<?php

// Bitte hier Ihre Daten eintragen:

$servername = "192.168.0.1";   // IP-Adresse oder Name des Servers
$username = "Anonym";      // Username für die MySQL-Datenbank
$password = "";      // Passwort für die MySQL-Datenbank
$database_name ="horst123";   // Name der Datenbank auf dem Server

// Ab hier nichts mehr ändern!

$db = mysql_connect("$servername", "$username", "$password");

?>


Name der Datei guestebuch_add.php
Code: Select all
<?php
error_reporting(0);

      $datum = date("d.m.Y");
     
      include "mysql_connect.php";

      if ($name == "" || $text == "")
      {
        echo "<meta http-equiv=\"refresh\" content=\"0; URL=index.php\">";
      }     
      else
      {
     
      if ($homepage == "http://")
      {
        $homepage = "";
      }
           
      $sqlab = "insert guestbook";
      $sqlab .= "(name, email, homepage, text, datum) values ";
      $sqlab .= "('$name', '$email', '$homepage', '$text', '$datum')";

      mysql_db_query("$database_name", $sqlab);

      $num = mysql_affected_rows();
      if ($num>0)
         
         echo "<meta http-equiv=\"refresh\" content=\"0; URL=index.php\">";

      mysql_close($db);
     
      }
?>


Name der Datei guestebuch_new.php
Code: Select all
<html>

<form method="POST" action="guestbook_add.php">
<table>
<tr><td><font face="Verdana" size="1">Name</font></td><td>
  <font size="1" face="Verdana"><input type="text" name="name" size="40"></font></td></tr>
<tr><td><font face="Verdana" size="1">Email</font></td><td>
  <font face="Verdana" size="1"><input type="text" name="email" size="40"></font></td></tr>
<tr><td><font face="Verdana" size="1">Homepage</font></td><td>
  <font face="Verdana" size="1"><input type="text" name="homepage" size="40" value="http://"></font></td></tr>
<tr><td><font face="Verdana" size="1">Text</font></td><td>
  <font face="Verdana" size="1"><textarea rows="6" name="text" cols="50"></textarea></font></td></tr>
</table>
<font size="1" face="Verdana">
<input type="submit" value="Abschicken" name="Senden"> </font>
</form>

</html>


Kann mir dabei vielleicht jemand weiter Helden

Mfg apachetester 8)
apachetester
 
Posts: 5
Joined: 14. October 2004 11:08

Postby Kristian Marcroft » 21. October 2004 06:27

Hi,

wo steht denn hier das Problem?
Du hast was "entwickelt" und hast das hier presigegeben...
und nu? Was erwartest du?

So long
KriS
User avatar
Kristian Marcroft
AF Moderator
 
Posts: 2962
Joined: 03. January 2003 12:08
Location: Diedorf


Return to PHP

Who is online

Users browsing this forum: No registered users and 5 guests