Problem in guestbook
Posted: Fri Oct 23, 2009 8:53 am
Hi all,
I have created a simple guest book in which user can log in and post comments guest book works perfect but the problem is i have add a edit link in all comments so user can edit comments but i want that users can only edit their own comments not others comment and users could only be seen edit link own there own comments how to do that here is code in which i have added a edit and delete link:
I have created a simple guest book in which user can log in and post comments guest book works perfect but the problem is i have add a edit link in all comments so user can edit comments but i want that users can only edit their own comments not others comment and users could only be seen edit link own there own comments how to do that here is code in which i have added a edit and delete link:
Code: Select all
$sql6 = mysql_query("SELECT commentid,title,comments FROM comment ");
$sql7 = mysql_query("SELECT userid FROM registration WHERE username = '$_SESSION[username]' ");
$sql_set12 = mysql_fetch_assoc($sql7);
while ($sql_set11 = mysql_fetch_assoc($sql6)) {
echo "<center>
<table width='60%' border='1' style='border-collapse:collapse;border:1px solid #EEEDDD;'>";
echo "<tr>
<td width='30%' height='90px'>
<b>Title:$sql_set11[title]</b><br />
</td>
<td width='70%' height='90px'>
<b>$sql_set11[comments]</b><br /><br />";
$_SESSION['admin_userid'] = $sql_set12['userid'];
if ($_SESSION['admin_userid'] == 23) {
echo "<b><a href='authenticate.php?do=edit&commentid=$sql_set11[commentid]'>Edit</a></b> <b><a href='authenticate.php?do=del&commentid=$sql_set11[commentid]'>Delete</a></b>";
}
echo "</td>
</tr>";
echo "</table><br />
</center>";
}