[PHP] Simples Forum

Dieses Thema im Forum "Webentwicklung" wurde erstellt von DOWNandOUT, 26. April 2008 .

Schlagworte:
  1. 26. April 2008
    Simples Forum

    Hi, nen Kumpel von mir lernt grad PHP und ich spiel ein bissl mit CSS rum, also haben wir uns überlegt mal eine Simple forensoftware zu schreiben. Aufwand ca. 2 Stunden. Design: Nur in CSS was gezaubert.

    Features:
    *Themenanzeige
    *Thema erstellen

    Ja hier mal der Source:

    style.css
    Code:
    body {
    background-color: #000000;
    }
    
    .header {
    height: 100px;
    width: 100%;
    border: 1px solid #000000;
    background-color: #666666;
    }
    
    .navigation {
    height: 30px;
    width: 100%;
    border: 1px solid #000000;
    background-color: #B2B2B2;
    }
    
    .forumbg {
    height: 500px;
    width: 100%;
    border: 1px solid #000000;
    background-color: #4C4C4C;
    }
    
    .foren {
    margin-top: 40px;
    margin-left: 110px;
    height: 400px;
    width: 80%;
    border: 1px solid #000000;
    background-color: #D9D9CC;
    }
    
    .thema {
    margin-top: 4px;
    margin-left: 4px;
    height: 30px;
    width: 99%;
    border: 1px solid #000000;
    background-color: #00FF00;
    }
    
    a:visited {
    color: #000000;
    text-decoration: none;
    }
    
    a:active {
    color: #000000;
    text-decoration: none;
    }
    
    a:link {
    color: #000000;
    text-decoration: none;
    }
    
    div.thema:hover {
    background-color: #66FF66;
    }
    
    .inhalt {
    margin-top: 4px;
    margin-left: 4px;
    height: 99%;
    width: 99%;
    border: 1px solid #000000;
    background-color: #00FF00;
    }
    
    a.button
     {
     margin-left: 5px;
     margin-top: 10px;
     font-family:Verdana;
     font-size:12px;
     color: #000000;
     background-Color: #B2B2B2;
     border: 1px solid #000000;
     text-decoration: none;
     width: 55px;
     text-align: center;
     }
    a.button:hover
     {
     Color: #000000;
     background-Color: #C0C0C0;
     border: 1px solid #000000;
     text-decoration: none;
     } 
    index.php
    PHP:
    <!doctype html public "-//W3C//DTD HTML 4.0 //EN">
    <html>
    <head>
    <title>Forensoftware</title>
    <link rel="stylesheet" href="style.css" type="text/css"/>
    </head>
    <body>
    <div class="header">
    <center><font size="12"><a href="index.php">Test Forum</a></font></center>
    </div>
    <div class="navigation">
    </div>
    <div class="forumbg">
    <div class="foren">
    <a href="answer.php" class="button">Neues Thema erstellen</a>
    <table cellspacing="0" cellpadding="0.5" width="99%">
    <tr>
    <td width="80%" align="center"><b>Thema</b></td>
    <td width="20%" align="center"><b>Ersteller</b></td>
    </tr>
    <?php
    $sqlhost 
    'localhost' ;
    $sqluser  'root' ;
    $sqlpass  'root' ;
    $sqldata  'Datenbank' ;
    $connect  mysql_connect ( $sqlhost $sqluser $sqlpass );
    mysql_select_db ( $sqldata $connect );

    $query  "SELECT * FROM `test_forum` ORDER BY `id` ASC LIMIT 8" ;
    $result  mysql_query ( $query ) OR die( mysql_error ());
    while(
    $row  mysql_fetch_array ( $result )) {
    echo 
    '<tr><td>' ;
    echo 
    '<div class="thema"><font size="5"><a href="board.php?id=' . $row [ 'id' ]. '">' . $row [ 'name' ]. '</a></font><br /></div>' ;
    echo 
    '</td>' ;
    echo 
    '<td>' ;
    echo 
    '<div class="thema"><font size="5"><a href="#" onclick="javascript:alert(\'IP-Adresse: 127.0.0.1\')">' . $row [ 'ersteller' ]. '</a></font><br /></div>' ;
    echo 
    '</td></tr>' ;
    }
    ?>
    </table>
    <br /><center><b><< | >></b></center>
    </div>
    </div>

    </body>
    </html>
    board.php
    PHP:
    <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
    <html>
    <head>
           <title>Forensoftware</title>
           <link rel="stylesheet" href="style.css" type="text/css"/>
    </head>
    <body>
    <div class="header">
    <center><font size="12"><a href="index.php">Test Forum</a></font></center>
    </div>
    <div class="navigation">
    </div>
    <div class="forumbg">
    <div class="foren">
    <table cellspacing="0" cellpadding="0.5" width="99%">
    <tr>
    <td width="100%" align="center"><b>Thema</b></td>
    </tr>
    <?php
    $id 
    $_GET [ id ];

    $sqlhost  'localhost' ;
    $sqluser  'root' ;
    $sqlpass  'root' ;
    $sqldata  'Datenbank' ;
    $connect  mysql_connect ( $sqlhost $sqluser $sqlpass );
    mysql_select_db ( $sqldata $connect );

    $query  "SELECT * FROM `test_forum` WHERE `id` = " . $id ;
    $res  mysql_query ( $query ) OR die( mysql_error ());
    while(
    $row  mysql_fetch_array ( $res )) {
        echo 
    '<tr><td><div class="thema"><font size="5"><a href="#">Thema: ' . $row [ 'name' ]. '</a> || Ersteller: ' . $row [ 'ersteller' ]. ' </font><br /></div></td></tr>' ;
        echo 
    '<tr><td><div class="inhalt"><font size="5">' . $row [ 'inhalt' ]. '</font><br /></div></td></tr>' ;
    }
    ?>
    </table>
    <br /><center><b><a href="index.php">Zurück</a></b></center>
    </body>
    </html>
    answer.php
    PHP:
    <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> 
    <html>
    <head>
           <title>Forensoftware</title>
           <link rel="stylesheet" href="style.css" type="text/css"/>
    </head>
    <body>
    <div class="header">
    <center><font size="12"><a href="index.php">Test Forum</a></font></center>
    </div>
    <div class="navigation">
    </div>
    <div class="forumbg">
    <div class="foren">
    <table cellspacing="0" cellpadding="0.5" width="99%">
    <tr>
    <td width="100%" align="center"><b>Thema</b></td>
    </tr>
    <form method="post">
    <?php
    $sqlhost 
    'localhost' ;
    $sqluser  'root' ;
    $sqlpass  'root' ;
    $sqldata  'Datenbank' ;
    $connect  mysql_connect ( $sqlhost $sqluser $sqlpass );
    mysql_select_db ( $sqldata $connect );
    $thema  $_POST [ 'name' ];
    $ersteller  $_POST [ 'ersteller' ];
    $inhalt  nl2br ( $_POST [ 'inhalt' ]);

    IF (
    $_POST [ 'submit' ]) {
    $query  "INSERT INTO `test_forum` (`name`,`inhalt`,`ersteller`) VALUES ('" . $thema . "', '" . $inhalt . "', '" . $ersteller . "')" ;
    mysql_query ( $query ) OR die( mysql_error ());
    }
    ?>
    <tr><td><div class="thema"><font size="5">Thema: <input type="text" name="name"> || Dein Name: <input type="text" name="ersteller"></font><br /></div></td></tr>
    <tr><td><div class="inhalt">Inhalt:<br />   <textarea rows="10" cols="50" name="inhalt"></textarea><br /><br /><input type="submit" name="submit" value="Abschicken"><br /><br /></div></td></tr>
    </form>
    </body>
    </html>
    SQL Struktur:
    Code:
     CREATE TABLE `test_forum` (
    `id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
    `name` VARCHAR( 255 ) NOT NULL ,
    `inhalt` TEXT NOT NULL ,
    `ersteller` VARCHAR( 100 ) NOT NULL ,
    PRIMARY KEY ( `id` )
    ) TYPE = MYISAM CHARACTER SET latin1 COLLATE latin1_german1_ci 
    Feedback erwünscht
     
  2. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.