simpel-forum

Gesponsorde koppelingen

PHP script bestanden

  1. simpel-forum

« Lees de omschrijving en reacties

//////Forum.php\\\\\

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<div align="center">
  
  <table border="0" cellpadding="1" cellspacing="0" width="750px">
        <tr>
            <td>Topic naam</td>
            <td>Datum</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
  </table>

   <table border="0" cellpadding="1" cellspacing="0" width="750px">
        
        <?php
    include("connect.php");

    $sql = "SELECT id,titel,datum FROM topics ORDER BY id DESC";
    $res = mysql_query($sql);

    
    
    if (mysql_num_rows($res) >= 1)
    {

        while ($row = mysql_fetch_array($res))
        {

    // het aantal reacties weergeven
                $nsql = "SELECT tid FROM replys WHERE tid = '" . $row[id] . "'";            
    $nres = mysql_query($nsql);
    $msg = mysql_num_rows($nres);
    
            $row['datum'] = substr($row['datum'], 0, 10);
            
                echo "
                
                <tr>
                    <td><a href="
replys.php?id=" . $row['id'] . " " >" . $row['titel'] . "</a></td>
                    <td><div align="
center">" . $row['datum'] . "</div></td>
                </tr>
                "
;
            }
    }

    else
    {
        echo "Er zijn nog geen topics.";
    }


    

?>

    </table>
  
  
  
  
    </div>

////replys.php\\\\
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<div align="center">
      <div style="text-align:left">
  
  <div align="center">
  <table width="70%" border="0" height="auto" align="left" style="text-decoration:none; size:auto; font-size:12px;">
  <tr>
    <td><?php
    include("connect.php");  
    include("functions.php");

    echo "<a href="forum.php"> << Terug</a><p><br><br>";

    $sql = "SELECT id,titel,bericht,datum,naam FROM topics WHERE id = '" . $_GET['id'] . "'";
    $res = mysql_query($sql);
    
    $row = mysql_fetch_array($res);
    
    $row['bericht'] = nl2br($row['bericht']);
    
    echo "<b>" . $row['titel'] . " door " . $row['naam'] . " op " . $row['datum'] . " :</b><p><br><br>";
    
    $row['bericht'] = smilie($row['bericht']);
    echo $row['bericht'] . "<p><br><br><br>";
    
    
    echo "<b>Reacties:<br></b>";
        
    
    $csql = "SELECT naam,bericht,datum FROM replys WHERE tid = '" . $_GET['id'] . "'";
    $cres = mysql_query($csql);
    
    
    if (mysql_num_rows($cres) >= 1)
    {

        while ($row = mysql_fetch_array($cres))
        {

            echo "Door <b>" . $row['naam'] . "</b> op " . $row['datum'] . "<br>";
            
            $row['bericht'] = htmlentities($row['bericht']);
            
            $row['bericht'] = nl2br($row['bericht']);
            
            $row['bericht'] = smilie($row['bericht']);
            echo $row['bericht'] . "<p>";
        }
    }

    else
    {
             echo "Er zijn nog geen reacties.";
    }

    
    echo "Voeg een reactie <a href="addreply.php?id=" . $_GET['id'] . "">toe</a>";
    
?>
</td>
  
  
  
  
  </tr>
  </table>
          </div>
      </div>


////addreply.php\\\\

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include("connect.php");
include("functions.php");

if ($_POST['submit'] && $_POST['na_am'] && $_POST['beri_cht'])
{

$datum = date("d.m.Y");
$_POST['beri_cht'] = filter($_POST['beri_cht']);

$sql = "INSERT INTO replys SET id = '', naam = '" . $_POST['na_am'] . "', bericht = '" . $_POST['beri_cht'] . "', datum = '" . $datum . "', tid = '" . $_GET['id'] . "'";
$res = mysql_query($sql);

    if ($res)
    {

    echo "Reactie toegevoegd! Ga naar het <a href="replys.php?id=" . $_GET['id'] . "">topic</a>";
    }

    else
    {
    echo "Reactie <b>niet</b> toegevoegd! Probeer het <a href="" . $PHP_SELF . "">opnieuw</a>";
    }
}
  
elseif ($_POST['submit'] || $_POST['na_am'] || $_POST['beri_cht'])
{

echo "Niet alle velden ingevult! Probeer het <a href="" . $PHP_SELF . "">opnieuw</a>";
}

else
{
    
    echo "<center>";
    echo "<table border="0" cellspacing="0" cellpadding="5" align="center">";
    echo "<form method="POST" action="" . $PHP_SELF . "?id=" . $_GET['id'] . "\">";

  
    echo "<tr><td>Je naam:*</td></tr>";
    echo "<tr><td><input type="text" name="na_am"></td></tr>";
        
    echo "<tr><td> </td></tr>";

    
    echo "<tr><td>Bericht:*</td></tr>";
    echo "<tr><td><textarea name="beri_cht" rows="10" cols="90"></textarea></td></tr>";

    
    echo "<tr><td>Alle velden zijn verplicht! </td></tr>";

    
    echo "<tr><td><input type="submit" name="submit" value="Plaats!" class="buttons">&nbsp<input type="reset" value="Wis" class="buttons"></td></tr>";
    
    
    echo "</form>";
    echo "</table>";
    echo "</center>";
}


?>


////addtopic.php\\\\
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

include("connect.php");
include("functions.php");

if ($_POST['submit'] && $_POST['na_am'] && $_POST['beri_cht'] && $_POST['tit_el'])
{

$datum = date("d.m.Y");
$_POST['beri_cht'] = filter($_POST['beri_cht']);

$sql = "INSERT INTO topics SET id = '', titel = '" . $_POST['tit_el'] . "', bericht = '" . $_POST['beri_cht'] . "', datum = '" . $datum . "', naam = '" . $_POST['na_am'] . "'";
$res = mysql_query($sql);

    if ($res)
    {

    echo "Topic toegevoegd! Ga naar het <a href="forum.php">Forum overzicht</a>";
    }

    else
    {
    echo "Topic <b>niet</b> toegevoegd! Probeer het <a href="" . $PHP_SELF . "">opnieuw</a>";
    }
}
  
elseif ($_POST['submit'] || $_POST['na_am'] || $_POST['beri_cht'] || $_POST['tit_el'])
{

echo "Niet alle velden ingevult! Probeer het <a href="" . $PHP_SELF . "">opnieuw</a>";
}

else
{
    
    echo "<center>";
    echo "<table border="0" cellspacing="0" cellpadding="5" align="center">";
    echo "<form method="POST" action="" . $PHP_SELF . "">";

  
    echo "<tr><td>Je naam:*</td></tr>";
    echo "<tr><td><input type="text" name="na_am"></td></tr>";

    
    echo "<tr><td> </td></tr>";
    
    
    echo "<tr><td>Titel:*</td></tr>";
    echo "<tr><td><input type="text" name="tit_el"></td></tr>";

    
    echo "<tr><td> </td></tr>";

    
    echo "<tr><td>Bericht:*</td></tr>";
    echo "<tr><td><textarea name="beri_cht" rows="20" cols="100"></textarea></td></tr>";

    
    echo "<tr><td>Alle velden zijn verplicht! </td></tr>";

    
    echo "<tr><td><input type="submit" name="submit" value="Plaats!" class="buttons">&nbsp<input type="reset" value="Wis" class="buttons"></td></tr>";
    
    
    echo "</form>";
    echo "</table>";
    echo "</center>";
}


?>


////functions.php\\\\

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php

function filter($tekst)
{


$woorden = array ("kut", "lul", "kanker", "trut", "debiel", "mongool", "fuck", "bitch", "pussy", "eikel", "tering", "hoer", "klootzak", "tiefuslijer", "homo", "flikker");

$aantal = count($woorden);

for ($var = 0; $var < $aantal; $var++ )
{

$tekst = eregi_replace($woorden[$var], '*:)*', $tekst);
}


return $tekst;

}


function
smilie($tekst)
{


$smilie = array (":)", ":-o", ";)", ":S", ":'(", "(h)", "(a)", ":-#", "8-|", ":-*", ":^)", ":o)", "|-)", ":d", ":p", ":(", ":|", ":$", ":@", "(6)", "8o|", "^o)", "+o(", "*-)", "8-)", ":-O", ":s", "(H)", "(A)", ":O)", ":D", ":P", "8O|", "^O)", "+O(");

$img = array ("
<img src="
smilies/1.gif">", "
<img src="
smilies/2.gif">", "
<img src="
smilies/3.gif">", "
<img src="
smilies/4.gif">", "
<img src="
smilies/5.gif">", "
<img src="
smilies/6.gif">", "
<img src="
smilies/7.gif">", "
<img src="
smilies/8.gif">", "
<img src="
smilies/9.gif">", "
<img src="
smilies/10.gif">", "
<img src="
smilies/11.gif">", "
<img src="
smilies/12.gif">", "
<img src="
smilies/13.gif">", "
<img src="
smilies/14.gif">", "
<img src="
smilies/15.gif">", "
<img src="
smilies/16.gif">", "
<img src="
smilies/17.gif">", "
<img src="
smilies/18.gif">", "
<img src="
smilies/19.gif">", "
<img src="
smilies/20.gif">", "
<img src="
smilies/21.gif">", "
<img src="
smilies/22.gif">", "
<img src="
smilies/23.gif">", "
<img src="
smilies/24.gif">", "
<img src="
smilies/25.gif">", "
<img src="
smilies/2.gif">", "
<img src="
smilies/4.gif">", "
<img src="
smilies/6.gif">", "
<img src="
smilies/7.gif">", "
<img src="
smilies/12.gif">", "
<img src="
smilies/14.gif">", "
<img src="
smilies/15.gif">", "
<img src="
smilies/21.gif">", "
<img src="
smilies/22.gif">", "
<img src="
smilies/23.gif">");


$aantal = count($smilie);

for ($var = 0; $var < $aantal; $var++ )
{


$tekst = str_replace($smilie[$var], $img[$var], $tekst );

}


return $tekst;
}


?>


////connect.php\\\\

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
// mysql connectie
$user = "dbuser";
$dbpass = "pass";
$host = "localhost";
$dbdb = "database";

if (!mysql_select_db($dbdb, mysql_connect($host, $user, $dbpass)))
{

     echo "Database connectie mislukt.";
     exit();
}

?>



De tabellen:
///// replys /////
CREATE TABLE replys (
id int(11) auto_increment primary key,
naam varchar(30) not null,
bericht text not null,
tid int(11) not null,
datum varchar(16) not null
);

///// topics //////
CREATE TABLE topics (
id int(11) auto_increment primary key,
titel varchar(50) not null,
bericht text not null,
datum varchar(16) not null,
naam varchar(20) not null
);




Klaar

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.