simpele-gastenboek-v08

Gesponsorde koppelingen

PHP script bestanden

  1. simpele-gastenboek-v08

« Lees de omschrijving en reacties

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
#########################################
#                                      index.php                                   #
#########################################
<html>
<head>
<title>gastenboek van </title>
</head>

<body>
<br>
<center>
<a href="schijf.php"><b>teken het gastenboek</b></a><br>
<?php
require "connect.php";
require "functions.php";

    $page = isset($_GET['pagina']) ? $_GET['pagina'] : 1;
    $message_per_page = 5;
    $offset = ($page - 1) * $message_per_page;
    
    
    $sql = "SELECT count(*) FROM `gastenboek`";
    $res = mysql_query($sql);
    $num = mysql_result($res, 0);
    
    $page_nummers = ceil($num / $message_per_page);
    
    echo '<small>';
    for($i=1; $i<=$page_nummers; $i++) {
        if($page == $i) {    echo ' - <b>'.$i.'</b>';    }
        else             {    echo ' - <a href="index.php?pagina='.$i.'" title="go to page '.$i.'">'.$i.'</a>';    }
    }

    echo ' -</small><br>';
    
    $sql = "SELECT * FROM `gastenboek` ORDER BY `id` DESC LIMIT $offset, $message_per_page";
    $res = mysql_query($sql);
  
    while ($data = mysql_fetch_array($res)) {
        
        $id = $data['id'];
        $datum = date("d-m-y @ h:i", $data['datum']);
        $naam = $data['naam'];
        $email = $data['email'];
        $url = $data['url'];
        $woonplaats = $data['woonplaats'];
        $bericht = smilys($data['bericht']);
        $bericht = nl2br($bericht);
?>


<br>
<table width="638" height="2" border="1" bordercolor="#000000" cellspacing="0" cellpadding="6" >
  <tr>
    <td width="191" height="100%" valign="top">
    <?php
    echo "<b>Naam:</b> $naam<br><b>Woonplaats:</b> $woonplaats<br>";
    echo '<b>URL:</b><a  target="_blank" href="'.$url.'"><b>'.$url.'</b></a><br><b>Email:</b><a href="mailto:'.$email.'">'.$email.'</a>';
    
    ?>

    </td>
    <td width="441" height="100%" valign="top">
      <table width="441" border="1" cellpadding="4" cellspacing="0" bordercolor="#CCCCCC">
        <tr>
          <td width="466" height="17"><?php echo "<small><b>posted on $datum</b></small>"; ?></td>
        </tr>
      </table>
      <p><?php echo "$bericht"; ?></p></td>
  </tr>
</table>

<?php
}
?>

</center>
</body>
</html>

#########################################
#                                   schijf.php                                       #
#########################################
<title>teken het NO-ID gastenboek</title>
<style type="text/css">
<!--
body {
    background-image:  url(background.JPG);
}
-->
</style>
<center>
<?php
require "connect.php";
if(!isset($_POST['submit'])) {
?>

<form action="schijf.php" method="post">
<br><b>Teken het gastenboek...</b>
<table width="420" border="1" bordercolor="#000000" cellpadding="1" cellspacing="0">
  <tr>
    <td width="139"><b>Naam:</b></td>
    <td width="265"><input type="text" name="naam"></td>
    </tr>
  <tr>
    <td><b>Woonplaats:</b></td>
    <td><input type="text" name="woonplaats"></td>
    </tr>
  <tr>
    <td><b>Email:</b></td>
    <td><input type="text" name="email">
    </td>
    </tr>
  <tr>
    <td><b>URL:</b></td>
    <td><input type="text" name="url" value="http://"></td>
    </tr>
  <tr>
    <td valign="bottom"><b>Bericht:</b></td>
    <td><textarea name="bericht" cols="40" rows="6"></textarea></td>
    </tr>
</table>
<input type="submit" name="submit" value="submit">&nbsp;&nbsp;<input type="reset" name="reset" value="reset">
</center>
<br>



</form>
<?php

}

else {
    if((empty($_POST['naam'])) || (empty($_POST['bericht']))) {
    echo '<br><b>je hebt of je naam niet ingevult of geen bericht gescheven!<a href="schijf.php"><br>klik hier om terug te gaan</a></b>';
    }

    else {
    
    $naam = htmlentities($_POST['naam']);
    $woonplaats = htmlentities($_POST['woonplaats']);
    $email = htmlentities($_POST['email']);
    $url = htmlentities($_POST['url']);
    $bericht = addslashes($_POST['bericht']);
    $bericht = strip_tags($bericht);
    $datum = time();
    $ip = $_SERVER['REMOTE_ADDR'];
    
    $sql = "INSERT INTO `gastenboek_no-id_` SET `naam` = '$naam' , `woonplaats` = '$woonplaats' , `email` = '$email' , `url` = '$url' , `bericht` = '$bericht' , `datum` = '$datum' , `ip` = '$ip'";
    $res = mysql_query($sql);
    if($res) {
    echo '<br><b>je bericht is succesvol toegevoegd<br><a href="index.php">ga terug om je bericht te bekijken</a><br>je ip is:'.$ip.'</b>';
        }

        else {
        echo "er ging iets niet goed";
        }
      }
    }

?>

#########################################
#                                   functions.php                                  #
#########################################

<?php

function smilys($str) {
    
        $smiles = array (':D', ':)', ':|', ';)', ':(', ':P', ':S',':thumb:',':cheers:', ':biggrin:' , ':rolleyes:');
        $images = array("laugh.gif", "smile.gif", "verbaast.gif", "wink.gif", "sad.gif", "lol.gif", "hmzz.gif" ,"thumb.gif","cheers.gif","biggrin.gif" ,"rolleyes.gif");
        $num = count($smiles);
        
        for($i = 0; $i < $num; $i++) {
            $str = str_replace(strtolower($smiles[$i]), ' <img src="smilies/'.$images[$i].'" alt="'.substr($images[$i], 0, -4).'"> ', $str);
            $str = str_replace(strtoupper($smiles[$i]), ' <img src="smilies/'.$images[$i].'" alt="'.substr($images[$i], 0, -4).'"> ', $str);
        }

        return $str;
    }

    ?>

#########################################
#                                   connect.php                                   #
#########################################

<?php
$host
= "";
$naam = "";
$pass = "";
$db = "";

mysql_connect($host , $naam  , $pass);
mysql_select_db($db);

?>

 
 

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.