gastenboek-zonder-mysql
Gesponsorde koppelingen
PHP script bestanden
------------- index.php -----------
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?
echo "Klik <a href=\"toevoegen.php\">hier</a> om een bericht toe te voegen.<p>";
$file = fopen("counter.txt", "r");
$counter = fgets($file, 4096);
fclose($file);
for ($i = $counter; $i > 0; $i--)
{
if ($i < 10)
$i = "000" . $i;
elseif ($i < 100)
$i = "00" . $i;
elseif ($i < 1000)
$i = "0" . $i;
$get_file = $i . "_bericht.txt";
if (file_exists($get_file))
{
include($get_file);
echo "<br>";
}
}
?>
echo "Klik <a href=\"toevoegen.php\">hier</a> om een bericht toe te voegen.<p>";
$file = fopen("counter.txt", "r");
$counter = fgets($file, 4096);
fclose($file);
for ($i = $counter; $i > 0; $i--)
{
if ($i < 10)
$i = "000" . $i;
elseif ($i < 100)
$i = "00" . $i;
elseif ($i < 1000)
$i = "0" . $i;
$get_file = $i . "_bericht.txt";
if (file_exists($get_file))
{
include($get_file);
echo "<br>";
}
}
?>
------- toevoegen.php -------
Code (php)
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
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
<?
if ($_POST['submit'] && $_POST['naam'] && $_POST['bericht'])
{
$post_naam = htmlentities($_POST['naam']);
$post_bericht = htmlentities($_POST['bericht']);
$post_bericht = nl2br($post_bericht);
$gastenboek_tekst = "<b>Geschreven door</b> " . $post_naam . " <b>op</b> " . date('d.m.Y H:i') . "<br>\n<b>Bericht:</b><br>" . $post_bericht . "<p>\n\n<hr align=\"left\" width=\"200\">\n\n";
$file = fopen("counter.txt", "r");
$num = fgets($file, 4096);
fclose($file);
$ornum = $num + 1;
$num = $num + 1;
if ($num < 10)
$num = "000" . $num;
elseif ($num < 100)
$num = "00" . $num;
elseif ($num < 1000)
$num = "0" . $num;
$filetoopen = $num . "_bericht.txt";
$file = fopen($filetoopen, "a");
fwrite($file, $gastenboek_tekst);
fclose($file);
$cfile = fopen("counter.txt", "w");
fwrite($cfile, $ornum);
fclose($cfile);
echo "Bericht toegevoegd.<p>";
echo "Klik <a href=\"index.php\">hier</a> voor de berichten.";
}
else
{
echo "Bedacht? Klik <a href=\"index.php\">hier</a> voor de berichten.<p>";
echo "<form method=\"POST\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "Naam:<br><input type=\"text\" name=\"naam\" value=\"" . htmlentities($_POST['naam']) . "\"><br>";
echo "Bericht:<br><textarea name=\"bericht\" rows=\"5\" cols=\"45\">" . htmlentities($_POST['bericht']) . "</textarea><br>";
echo "<input type=\"submit\" name=\"submit\" value=\"Bericht toevoegen\">";
echo "</form>";
}
?>
if ($_POST['submit'] && $_POST['naam'] && $_POST['bericht'])
{
$post_naam = htmlentities($_POST['naam']);
$post_bericht = htmlentities($_POST['bericht']);
$post_bericht = nl2br($post_bericht);
$gastenboek_tekst = "<b>Geschreven door</b> " . $post_naam . " <b>op</b> " . date('d.m.Y H:i') . "<br>\n<b>Bericht:</b><br>" . $post_bericht . "<p>\n\n<hr align=\"left\" width=\"200\">\n\n";
$file = fopen("counter.txt", "r");
$num = fgets($file, 4096);
fclose($file);
$ornum = $num + 1;
$num = $num + 1;
if ($num < 10)
$num = "000" . $num;
elseif ($num < 100)
$num = "00" . $num;
elseif ($num < 1000)
$num = "0" . $num;
$filetoopen = $num . "_bericht.txt";
$file = fopen($filetoopen, "a");
fwrite($file, $gastenboek_tekst);
fclose($file);
$cfile = fopen("counter.txt", "w");
fwrite($cfile, $ornum);
fclose($cfile);
echo "Bericht toegevoegd.<p>";
echo "Klik <a href=\"index.php\">hier</a> voor de berichten.";
}
else
{
echo "Bedacht? Klik <a href=\"index.php\">hier</a> voor de berichten.<p>";
echo "<form method=\"POST\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "Naam:<br><input type=\"text\" name=\"naam\" value=\"" . htmlentities($_POST['naam']) . "\"><br>";
echo "Bericht:<br><textarea name=\"bericht\" rows=\"5\" cols=\"45\">" . htmlentities($_POST['bericht']) . "</textarea><br>";
echo "<input type=\"submit\" name=\"submit\" value=\"Bericht toevoegen\">";
echo "</form>";
}
?>
----------- counter.txt -------------