simpel-forum-met-mysql

Gesponsorde koppelingen

PHP script bestanden

  1. simpel-forum-met-mysql

« Lees de omschrijving en reacties

///// topics.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
<html>
<head>
<title></title>
</head>

<link rel="stylesheet" href="styles.css" type="text/css" media="screen">

<body>

<?
    include("connect.php");

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

    echo "<b>Topic overzicht</b><p>";
    
    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 "<a href=\"replys.php?id=" . $row['id'] . "\">" . $row['titel'] . "</a> (" . $msg . ") op " . $row['datum'] . "<br>";
        }
    }

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


     echo "<p>Nieuwe topic <a href=\"addtopic.php\">toevoegen</a>";

?>

</body>
</html>
<noscript><noscript><plaintext><plaintext>




//// 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
<html>
<head>
<title></title>
</head>

<link rel="stylesheet" href="styles.css" type="text/css" media="screen">

<body>

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

    echo "<a href=\"topics.php\">Topic overzicht</a><p>";

    $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'] . "</b> door " . $row['naam'] . " op " . $row['datum'] . "<p>";
    
    $row['bericht'] = smilie($row['bericht']);
    echo $row['bericht'] . "<p>";
    
    
    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>";
    
    echo "<p><a href=\"topics.php\">Topic overzicht</a></p>";
?>

</body>
</html>
<noscript><noscript><plaintext><plaintext>




///// 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
56
57
58
59
60
61
62
63
64
65
66
67
<html>
<head>
<title></title>
</head>

<link rel="stylesheet" href="styles.css" type="text/css" media="screen">

<body>

<?
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=\"5\" cols=\"15\"></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>";
}


?>

</body>
</html>
<noscript><noscript><plaintext><plaintext>




///// 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
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<title></title>
</head>

<link rel="stylesheet" href="styles.css" type="text/css" media="screen">

<body>

<?

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=\"topics.php\">topic 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=\"5\" cols=\"15\"></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>";
}


?>

</body>
</html>
<noscript><noscript><plaintext><plaintext>



///// 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
<?

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;
}


?>



en last but not least ///// 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
<?
// 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();
}

?>


En dat was het! Simpel toch?

 
 

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.