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
[PHP HELP] User Rank
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="Markshall" data-source="post: 235006" data-attributes="member: 1872"><p>I <strong>think</strong> you'd have to do:</p><p></p><p>[PHP]<?php</p><p>$rank = mysql_result(mysql_query("SELECT `rank` FROM `users` WHERE `id` = '" . $_SESSION['id'] . "'"), 0) or die(mysql_error());</p><p>if ($rank > 3) {</p><p> echo 'lol';</p><p>}</p><p>?>[/PHP]</p><p></p><p>Another thing you should do is sanitize your $_SESSION variables, you can do this in a global file and then include it into each PHP file where you will be using a database query. This is because I'm sure users can change $_SESSION data and change it to be able to do SQL injections. Either that <strong>or</strong> look into <a href="http://php.net/manual/en/book.mysqli.php" target="_blank">MySQLi</a> and specifically check out prepared statements.</p><p></p><p>I usually create a class aimed at users and create a method called getRow or something which accepts 2 parameters, the user ID and the row to fetch a value from, the method will then return the value of the row, if any.</p></blockquote><p></p>
[QUOTE="Markshall, post: 235006, member: 1872"] I [B]think[/B] you'd have to do: [PHP]<?php $rank = mysql_result(mysql_query("SELECT `rank` FROM `users` WHERE `id` = '" . $_SESSION['id'] . "'"), 0) or die(mysql_error()); if ($rank > 3) { echo 'lol'; } ?>[/PHP] Another thing you should do is sanitize your $_SESSION variables, you can do this in a global file and then include it into each PHP file where you will be using a database query. This is because I'm sure users can change $_SESSION data and change it to be able to do SQL injections. Either that [b]or[/b] look into [URL='http://php.net/manual/en/book.mysqli.php']MySQLi[/URL] and specifically check out prepared statements. I usually create a class aimed at users and create a method called getRow or something which accepts 2 parameters, the user ID and the row to fetch a value from, the method will then return the value of the row, if any. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
[PHP HELP] User Rank
Top