Aims:
CREATE TABLE comments_table ( id INT NOT NULL AUTO_INCREMENT, url VARCHAR(255) NOT NULL, username VARCHAR(255) NOT NULL, timestamp TIMESTAMP(14), subject VARCHAR(255) NOT NULL, message TEXT NOT NULL, inreplytoid INT, PRIMARY KEY (id) );
username
)
id
)
inreplytoid
to record the id of
that previous comment; if it is the first comment in a 'thread',
inreplytoid
will be NULL
<a href="enter.php?url=wombats.html">Write a comment</a> <a href="list.php?url=wombats.html">Read comments</a>Note the hard-coding of a query string in the URL
<a href="enter.php?url= <?php echo $_SERVER['PHP_SELF']; ?>">Write a comment</a>Note, this means every web page is now a
.php
file, not
.html
enter.php
enter.php
is basically an XHTML form for entering a commenttype="hidden"
)enter.php
is a PHP script, not an XHTML document?
textarea
for the user's message: in (X)HTML, this has its
own tag (not input
)
dbconnect.php
dbconnect.php
include
this file
using:
include('dbconnect.php');
store.php
checks the user's input and stores it in the databaselist-simple.php
: a simple listlist.php
: a recursive version, that lists comments in 'threaded' fashionshow.php
displays a comment in detailstore.php
$sql = "SELECT * FROM users WHERE username = '{$username}';";
store.php
mysql_real_escape_string
function