:\\/\.,\?;'\"]+)/i", '', $text), ENT_QUOTES, 'UTF-8')); } //////////////////////////// //Part 2: Connect to DB //////////////////////////// //If the DB file does NOT exist - Create it if (!is_file("philip_data")){ //Open a connection $dbc = sqlite_open("philip_data"); //Create table $query = "CREATE TABLE guestbook (inputId PRIMARY KEY, inputText TEXT NOT NULL);"; sqlite_query($dbc,$query); } else { //Open a connection $dbc = sqlite_open("philip_data"); } //////////////////////////// //Part 3: Add new comments and show guestbook //////////////////////////// if ($_POST['message']){ //Clean the Message sanitize_text($_POST['message']); //Clean the Name sanitize_text($_POST['name']); $tid = date("H:i:s d/m-Y"); //Create Guest Book log $mess = "Posted by: {$_POST['name']} on $tid

{$_POST['message']}

"; $query = "INSERT INTO guestbook (inputText) VALUES ('$mess');"; sqlite_query($dbc,$query); header("Location: {$_SERVER['PHP_SELF']}"); } //Select all the entries $query = "SELECT inputText FROM guestbook ORDER BY inputId DESC;"; $array = sqlite_single_query($dbc,$query); //If more than 15 pages if(count($array)>15){ $extrapages = floor(count($array)/15); $extrapages++; if (count($array)%15 == 0){ $extrapages--; } if($_GET['page']){ $num = (int)$_GET['page'] * 15; for($i=$num;$i" . "
" . "Navn:
" . "Melding

" . "
"; if($array && is_array($array)){ foreach ($array as $input){ echo "$input\n"; } } elseif ($array){ echo "$array"; } else { echo "Ingen innleg enda!"; } echo ""; if ($extrapages != 0){ echo extrapages($extrapages); } function extrapages($num){ $to = "
"; for($i=0;$i<$num;$i++){ $top = $i+1; $to .= "$top "; } $to .= "
"; return $to; } ?>