Hoe doe ik dit?

Gestart doorSkytop6 reacties52 weergaven

7 berichten · pagina 1 van 1

Skytop

Lid · Topicstarter

Berichten
1.101
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Hoe doe ik een soort admin panel?

Wat ik denk:
een rij invoegen met de naam admin , tinyint.
En als het 0 is = geen admin
en als het 1 is = admin

Wat ik weet:
Dat je iets zoals dit zou moeten doen:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$rownums[/COLOR] [COLOR= #007700]=[/COLOR] mysql_row_nums[COLOR= #007700][[/COLOR][COLOR= #0000BB]$connect[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$rownums[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
 [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent geen admin!"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
 [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent admin!"[/COLOR][COLOR= #007700];[/COLOR]
?>


Is dit juist? Of niet?
Kan iemand me helpen?

Skytop
0
Berichten
6.144
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$qQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Query"[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qQuery[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]admin[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Geen admin[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]admin[/COLOR][COLOR= #007700];
    }
}[/COLOR]
?>
0
Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$qQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Query"[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qQuery[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]admin[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je bent geen admin[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je bent admin[/COLOR][COLOR= #007700];
    }
}[/COLOR]
?>


volgens mij zo wel

oh xd zag de post van jponsen niet
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hmdesign schreef:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$qQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Query"[/COLOR][COLOR= #007700]);[/COLOR]


[URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qQuery[/COLOR][COLOR= #007700])) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$qFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]admin[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je bent geen admin[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]je bent admin[/COLOR][COLOR= #007700];
    }
}[/COLOR]
?>
volgens mij zo wel

oh xd zag de post van jponsen niet

Ga alsjeblieft niet iemand anders script kopieeren en dan doen of je het zelf hebt bedacht..

Maar ik zou gewoon gaan voor een kolom in de leden tabel ipv een hele eigen tabel hiervoor.
Dan krijg je dus zoeits:

[COLOR= #0000BB]<?php
$UserQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT userssssss"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$UserQuery[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
[COLOR= #0000BB]$UserFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$UserQuery[/COLOR][COLOR= #007700]);
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$UserFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]admin[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]){[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent geen admin"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent admin"[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Rik

Lid

Berichten
18.393
Reputatie
0
Punten
0,04
Lid sinds
Laatst gezien
Je kan ook doen

"SELECT 1 FROM users WHERE id = $_SESSION[id] AND admin = 1"

Als mysql_num_rows dan 0 is -> ingelogde gebruiker is geen admin. Anders is hij wel een admin.

Echter, zou ik werken met een permissiesysteem. Maarja, dat is net een stuk lastiger uit te leggen.
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Je kan ook doen

"SELECT 1 FROM users WHERE id = $_SESSION[id] AND admin = 1"

Als mysql_num_rows dan 0 is -> ingelogde gebruiker is geen admin. Anders is hij wel een admin.

Echter, zou ik werken met een permissiesysteem. Maarja, dat is net een stuk lastiger uit te leggen.
Inderdaad, ik werk ook met permissies.
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Rik schreef:
Je kan ook doen

"SELECT 1 FROM users WHERE id = $_SESSION[id] AND admin = 1"

Als mysql_num_rows dan 0 is -> ingelogde gebruiker is geen admin. Anders is hij wel een admin.

Echter, zou ik werken met een permissiesysteem. Maarja, dat is net een stuk lastiger uit te leggen.
Klopt, maar als het bijv. in een leden systeem is waar je toch al een fetch hebt van user data is het lijkt me makkelijker om het gewoon zo te controleren
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren