-4


I have a basic web application. I'm connected to the database. There's a lot of users in the database.
In my site, there is ability to add articles. I want an article to be edit-able just if it's mine. And I have a button that when it's clicked, article can be edited. I want that button to be shown near the article which is created by me. I don't want my article to be edit-able by another user. But I don't know how to do it. Should I start sessions or store something in variables or something?

And could anyone tell me how can I edit all articles if I'm an admin?. When admin is logged, I'm creating a session $_SESSION['admin'];

Any suggestions will be greatly appreciated.
Thanks.

tereško
  • 58,060
  • 25
  • 98
  • 150
Wolf
  • 75
  • 9
  • Please share which framework you are using, since you have tagged your question as MVC. – Musa Haidari Jul 24 '14 at 12:06
  • It's MVC. Sorry @putvande, I have tried in my another project but it doen't went well and it has gone, because I have reinstalled windows. I don't have anything to show now. – Wolf Jul 24 '14 at 12:09

1 Answers1

0

Yes, you must store login details of user in session so that you could identify who has logged in and give them the permission to edit articles accordingly. And for admin module, first-o-fall you must give some role id to admin and users which would differentiate between admin and other users. Then check whether admin has logged in or not using his role id. In this way you could allow admin to edit all articles. Hope this is the answer to your question.