gastenboek-zonder-database

Gesponsorde koppelingen

PHP script bestanden

  1. gastenboek-zonder-database

« Lees de omschrijving en reacties

index.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<?php
//kijk of opslag.txt bestaat, zo nee maakt  hij het aan
if(!file_exists('opslag.txt')){
fopen('opslag.txt','w+');
$test='bestaatniet';
}
else{
$array=file('opslag.txt');
$test="bestaat";
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Mijn eerste gastenboek</title>
<link href="style.css" type="text/css" rel="stylesheet" />
<meta name="author" content="ndm" />
<meta name="copyright" content="copyright (c) by nico de mooij" />
</head>
<body>
<form name="gastenboekform" action="index.php" method="post">

<fieldset class="inputgastenboek">
<table border="0"><tr><td>

<table border="0">
<tr><td>Naam: </td><td><input type="text" name="naam" /></td></tr>

<?php
// check of iemand een naam heeft ingevut
if(isset($_POST['try']) && $_POST['naam']==""){
echo '<tr><td colspan="2"><span class="error">U heeft geen naam ingevoerd</span></td></tr>';
$error='true';
}

?>


<tr><td>E-mailadres: </td><td><input type="text" name="email" /></td></tr>

<?php
// check of iemand een emailadres heeft ingevut
if(isset($_POST['try']) && $_POST['email']==""){
echo '<tr><td colspan="2"><span class="error">U heeft geen e-mailadres ingevoerd</span></td></tr>';
$error='true';
}

?>


<tr><td>Bericht: </td><td></td></tr>
</table>
<textarea name="bericht" cols="50" rows="5"></textarea>
<table border="0">

<?php
// check of iemand een bericht heeft ingevut
if(isset($_POST['try']) && $_POST['bericht']==""){
echo '<tr><td colspan="2"><span class="error">U heeft geen bericht ingevoerd</span></td></tr>';
$error='true';
}

?>


<tr><td><input type="reset" name="reset" value="wis invoer" /></td><td><input type="submit" name="try" value="verzend" /></td></tr>
</table>
</td><td valign="top">
<fieldset class="smile">
<legend class="smile">smilies</legend>
<table border="0"><tr>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + ':) '"><img src="images/smile1.gif" alt="blij" border="0" height="15" width="15" /></a></td>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + ':D '"><img src="images/smile2.gif" alt="uberhappy" border="0" height="15" width="15" /></a></td>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + '}:-&lt; '"><img src="images/smile3.gif" alt="boze blik" border="0" height="15" width="15" /></a></td>
</tr><tr>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + ':S '"><img src="images/smile4.gif" alt="sorry" border="0" height="15" width="15" /></a></td>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + ':P '"><img src="images/smile5.gif" alt="lekker puh" border="0" height="15" width="15" /></a></td>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + ';) '"><img src="images/smile6.gif" alt="knipoog" border="0" height="15" width="15" /></a></td>
</tr><tr>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + '::) '"><img src="images/smile9.gif" alt="slik" border="0" height="15" width="15" /></a></td>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + ':( '"><img src="images/smile7.gif" alt="snif" border="0" height="15" width="15" /></a></td>
<td><a onclick="document.gastenboekform.bericht.value=document.gastenboekform.bericht.value + 'H) '"><img src="images/smile8.gif" alt="cool eh" border="0" height="15" width="15" /></a></td>
</tr></table>
</fieldset>
</td></tr></table>

<?php
// keuze tussen alles laten zien en de 5 recentste laten zien

if($_GET['show']=="vijf"){
echo '<a href="?show=nietvijf">laat alles zien</a>';
}
else{
echo '<a href="?show=vijf">laat de 5 recentste zien</a>';
}

?>


</fieldset>
</form>

<?php
if(isset($_POST['try']) && $error!="true"){
// haalt extra gevegevens op
$time = date(H .':' . i .':' . s); //tijd van verzenden
$date = date(j .' '. M .' '. Y); //datum van verzenden
$ip = $_SERVER['REMOTE_ADDR']; //iemands ip-adres, kan je iemand op bannen
}
if(isset($_POST['try']) && $error!="true"){
// gaat in opslag.txt schrijven, opent hem
$file=fopen('opslag.txt','a'); //opent opslag.txt
$enter='
'
;

//enters uit het bericht halen
$bericht=str_replace($enter,'%',$_POST['bericht']);

//zet smilies erin
$bericht=str_replace('::)','<img src="images/smile9.gif" alt="slik" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace(':)','<img src="images/smile1.gif" alt="blij" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace(':D','<img src="images/smile2.gif" alt="uberhappy" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace('}:-<','<img src="images/smile3.gif" alt="boze blik" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace(':S','<img src="images/smile4.gif" alt="sorry" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace(':P','<img src="images/smile5.gif" alt="lekker puh" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace(';)','<img src="images/smile6.gif" alt="knipoog" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace(':(','<img src="images/smile7.gif" alt="snif" border="0" height="15" width="15" />',$bericht);
$bericht=str_replace('H)','<img src="images/smile8.gif" alt="cool eh" border="0" height="15" width="15" />',$bericht);

//start met schrijven
fwrite($file,$_POST['naam']);
fwrite($file,'&');
fwrite($file,$time);
fwrite($file,'&');
fwrite($file,$date);
fwrite($file,'&');
fwrite($file,$bericht);
fwrite($file,'&');
fwrite($file,$_POST['email']);
fwrite($file,'&');
fwrite($file,$ip);
fwrite($file,$enter);
//sluit opslag.txt weer af
fclose($file);
echo 'bedankt voor het schrijven in mijn gastenboek<br /><br />';
echo '<meta http-equiv="refresh" content="1;index.php" />';
}


// alle invoer laten zien
if($test='bestaat' && $_GET['show']=='vijf'){

//enters terugzetten
$i=0;
while($array[$i]){
$array[$i]=str_replace('%','<br />',$array[$i]);
$i++;
}


//opspiltsen
$j=0;
while($array[$j]){
$array[$j]=explode('&',$array[$j]);
$j++;
}

// bepaal het aantal keer dat er iets is ingevoerd, beginnend te tellen bij 0
$max=0;
while($array[$max]){
$max++;
}

$max--;

//geef alles weer
$l=0;
while($max>=0 && $l<5){
echo '<fieldset class="show">';
echo '<div class="show">';
echo '<table border="0" class="show" width="100%">';
echo '<tr>';
echo '<td align="left">';
echo $array[$max][0];
echo '</td>';
echo '<td align="right">';
echo $array[$max][1];
echo ' || ';
echo $array[$max][2];
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</div>';
echo '<div class="text">';
echo $array[$max][3];
echo '</div>';
echo '</fieldset>';
$l++;
$max--;
}


}
elseif($test='bestaat'){
// enters teregzetten
$i=0;
while($array[$i]){
$array[$i]=str_replace('%','<br />',$array[$i]);
$i++;
}


//opsplitsen
$j=0;
while($array[$j]){
$array[$j]=explode('&',$array[$j]);
$j++;
}

// bepaal het aantal keer dat er iets is ingevoerd, beginnend te tellen bij 0
$max=0;
while($array[$max]){
$max++;
}

$max--;


//geef alles weer
while($max>=0){

echo '<fieldset class="show">';
echo '<div class="show">';
echo '<table border="0" class="show" width="100%">';
echo '<tr>';
echo '<td align="left">';
echo $array[$max][0];
echo '</td>';
echo '<td align="right">';
echo $array[$max][1];
echo ' || ';
echo $array[$max][2];
echo '</td>';
echo '</tr>';
echo '</table>';
echo '</div>';
echo '<div class="text">';
echo $array[$max][3];
echo '</div>';
echo '</fieldset>';
$max--;
}

}

?>

</body>
</html>



de stylesheet 'style.css'

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
77
78
79
body {
font-family: verdana, arial, times new roman;
font-size: 10pt;
}
fieldset {
border: 1px solid #00B900;
background: #EEEEEE;
padding: 7px;
}
fieldset.inputgastenboek {
width: 530px;
}
fieldset.error {
width: 170px;
}
fieldset.error2 {
width: 190px;
}
fieldset.login {
width: 250px;
background: #FFFFFF;
}
span.verplicht {
font-size: 8pt;
color: red;
}
fieldset.smile {
border: 1px solid #0000B9;
padding: 7px;
width: 60px;
margin: 15px;
}
legend.smile {
background: #0000B9;
color: #FFFFFF;
}
a:active, a:link, a:visited {
color: #0000B9;
text-decoration: none;
}
a:hover {
color: #009900;
text-decoration: underline;
}
fieldset.show {
margin: 2px;
margin-bottom: 10px;
width: 530px;
padding: 0px;
}
div.show {
margin: 0px;
padding: 3px;
background: #00B900;
}
div.text {
margin: 0px;
padding: 3px;
}
table.show {
padding: 0px;
margin: 0px;
}
span.error {
font-size: 8pt;
color: red;
font-family: verdana, arial, times new roman;
}

h1.login {
background: #EEEEEE;
color: #00B900;
margin: 3px;
margin-top: 0px;
padding: 3px;
padding-top: 0px;
border-top: 1px solid #0000B9;
border-bottom: 1px solid #0000B9;
}

 
 

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.