Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Show content based on permission
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Berk" data-source="post: 397617" data-attributes="member: 63611"><p>Sup yo</p><p>I'm doing an admin panel (not habbo related fuck) </p><p>and i need to show some content based on user's permission level, like 1 2 3 or 4 or whatever. (btw im usin xampp rn)</p><p>My Php code below:[SPOILER="PHP CODE"]</p><p>[PHP]<?php</p><p>$servername = "localhost";</p><p>$username = "root";</p><p>$password = "";</p><p>$dbname = "lumino";</p><p></p><p>// Create connection</p><p>$conn = new mysqli($servername, $username, $password, $dbname);</p><p>// Check connection</p><p>if ($conn->connect_error) {</p><p> die("Connection failed: " . $conn->connect_error);</p><p>}</p><p></p><p>$sql = "SELECT permission FROM users WHERE username = 'Berkay'";</p><p>$result = $conn->query($sql);</p><p></p><p>if ($result->num_rows > 0) {</p><p> // output data of each row</p><p> while($row = $result->fetch_assoc()) {</p><p> </p><p> }</p><p>}</p><p>$permission = $row["permission"];</p><p>?><?php if($permission >= 1) { echo'<li class="parent"><a href="usermanagement.php"><i class="fa fa-users" aria-hidden="true"></i> User Management</a></li> ';} ?></p><p> [/PHP]</p><p>[/SPOILER]</p></blockquote><p></p>
[QUOTE="Berk, post: 397617, member: 63611"] Sup yo I'm doing an admin panel (not habbo related fuck) and i need to show some content based on user's permission level, like 1 2 3 or 4 or whatever. (btw im usin xampp rn) My Php code below:[SPOILER="PHP CODE"] [PHP]<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "lumino"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT permission FROM users WHERE username = 'Berkay'"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { } } $permission = $row["permission"]; ?><?php if($permission >= 1) { echo'<li class="parent"><a href="usermanagement.php"><i class="fa fa-users" aria-hidden="true"></i> User Management</a></li> ';} ?> [/PHP] [/SPOILER] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Show content based on permission
Top