How to set an admin for my website?

lets say i coded an eCommerce website that has some products in it and its now live.
How can i later go and put (lets say) a product “out of stock” ? without having to go to to source code to do it manually.

This heavily depends on how your site is structured and technologies used.

But let’s say you have a database of your inventory that gets queried when a user goes to view a product on the site. The database could contain the number of the product in stock and if that number is 0, you could mark that as out of stock automatically.

This is just an example.
As I said before though, the way you may wanna do this depends heavily on your site’s structure.

1 Like

yeah but isnt there a standar way to do this?
how do sites set an admin as “moderator” instead of changing the source code all the time?

you can do it with server side language javascript, php, ruby, java, or any language meant for that purpose.

the server itself would have to know the difference between the different types of users like take facebook for example, in that application each individual user is the admin of his own facebook page. and the data changes dynamically.

For example a user that is the owner of a page has abilities to Create, read, edit, and delete any data, maybe his friends would just have the option to Create new data to comment on his posts. Maybe someone who is not a friend would only be able to Read what is on his wall, but would not be allowed to make any posts… etc…

without having to go to to source code to do it manually.

that is the difference between a dynamic site and a static site.

some sites have admins, some have super admins that can add other admins. depends on the site I guess. the site needs to have a way to differentiate who is who. research web tokens, cookies, and sessions.

Remember there is code that exists on a users particular device (react for example) and then there would be code that only exists on the server. So if you were to say make a login system but you were only setting the state of “Authorized” and “unauthorized” on the front end that could be easily manipulated by a user as his device possesses that code.

example: if you use a simple react code (front end only) to make a simple login application you could just open the dev tools of the browser if you have react tools installed and change the states to whatever you wanted. it means that anyone that did this would have full access to Create, read, edit and delete data. However you would want some server logic to verify that the user is really who he says he is before executing those actions. does it make sense?

1 Like