I need login with cookies to hide comment form, from user who are not logged in.
Users can view article without login but can not comment without login
Database
CREATE TABLE IF NOT EXISTS `members` (
`id` bigint(12) NOT NULL AUTO_INCREMENT,
`fname` varchar(500) NOT NULL,
`lname` varchar(500) NOT NULL,
`email` varchar(250) NOT NULL,
`username` varchar(250) NOT NULL,
`pass` varchar(250) NOT NULL,
PRIMARY KEY (`id`,`username`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `articles` (
`id` bigint(12) NOT NULL AUTO_INCREMENT,
`userid` varchar(12) NOT NULL,
`catid` varchar(12) NOT NULL,
`title` varchar(500) NOT NULL,
`content` longtext NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
article.php
<?php
include('config.php');
$query="SELECT * FROM articles";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$title=$row["title"];
$content=$row["content"];
echo "$title";
echo "$content";
?>
<div id="addCommentContainer">
<p>Add a Comment</p>
<form id="addCommentForm" method="post" action="comment.php">
<div>
<input type="hidden" name="userid" id="id" />
<input type="hidden" name="articleid" id="id" />
<textarea name="body" id="body" cols="20" rows="5"></textarea>
<input type="submit" id="submit" value="Submit" />
</div>
</form>
</div>
<?php
}
?>