PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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:
Does your 'comment' table have a userid field/column? If not, that would be the issue. When saving a comment, you need to also save the userid of the user who's creating it. This way, you'd have a reliable mapping to associate comments to users.
When you make this change, you'd then simply need to update your $sql6 query line to include "userid" in the select fields. And you wouldn't even need the $sql7 query since all you'd have to do would be to compare $_SESSION['admin_userid'] to "userid" from $sql6.
Frelo wrote:Does your 'comment' table have a userid field/column? If not, that would be the issue. When saving a comment, you need to also save the userid of the user who's creating it. This way, you'd have a reliable mapping to associate comments to users.
When you make this change, you'd then simply need to update your $sql6 query line to include "userid" in the select fields. And you wouldn't even need the $sql7 query since all you'd have to do would be to compare $_SESSION['admin_userid'] to "userid" from $sql6.
Hope that helps!
Thanks for replying Frelo i will do this in other way but it's not working here is a new code: