⊗ppPmAuRR 433 of 447 menu

Registration With User Rights Separation in PHP

When adding user rights, we need to make changes to our registration. Now, when registering a user, we must specify their status in the INSERT query.

Usually, during initial registration, all users of our site receive the lowest status, which in our case is 'user':

<?php $query = "INSERT INTO users SET login='$login', password='$password', 'status'='user'"; ?>

Higher statuses are usually assigned by the administrator. They see the list of users in the admin panel and can make anyone, for example, an administrator.

How then will the first administrator appear on the site? The simplest way: register a regular user and make them an admin via PhpMyAdmin.

A more complex way: during the first launch on the hosting, run the site installation, ask for a login and password using a form, and register the very first user of the site, assigning them the administrator status.

Modify the registration code so that all added users receive the status 'user'.

Manually change the status of some user to 'admin'. Log in under this user.

Create a page admin.php that will only be accessible to users with the status 'admin'.

Display a list of all registered users of your site on the page admin.php in the form of a table. Let the table have two columns: login and status.

Modify the previous task so that a third column also appears, with a link that allows the admin to delete any user.

Modify the previous task so that the table rows with admins are colored red, and with regular users - green.

Modify the previous task so that one more column appears. In this column, the admin will be able to change user rights. Make it so that for all regular users there is a link make them an admin, and for an admin - a link make them a user.

Make it so that on all pages of the site, in the header, a registered user sees their login and status.

Modify the previous task so that for admins, the site header also shows a link to the admin panel.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline