once again, damn magic quotes...
[miniqdb.git] / submit.php
blobae0c9508ebc308ac1145aa716fb178f23add2321
1 <?php
3 /* miniqdb - A simple quote database written in PHP
4 Copyright (C) 2008 Ian Weller <ianweller@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
20 require "header.php";
22 // Gets args from POST
23 $quote = stripslashes_if_gpc_magic_quotes($_POST["quote"]);
25 // Replace IRC "<" and ">" characters with the HTML equivalent.
26 // Then strip newlines from the top and bottom of the quote.
27 $quote_lt = ereg_replace('<', '&lt;' , $quote);
28 $quote_gt = ereg_replace('>', '&gt;' , $quote_lt);
29 $quote_lb = trim($quote_gt);
31 // Insert into database as new. We leave out ID number cause the
32 // database will autoincrement that field by itself.
34 $st = $db->prepare('INSERT INTO miniqdb (epoch,quote) VALUES (?,?)');
35 $st->execute(array(date('U'), $quote_lb));
36 $id = $db->lastInsertId();
38 echo "<p>quote posted</p>";
39 echo "<p>Quote <a href=\"quote.php?id=$id\">$id</a> was just added.</p>";
40 echo "<p><a href=\"index.php\">Go back to the QDB</a></p>";
42 echo $footer;