[PHP]Reciving Specific Information From MySQL
To be more indepth what I'm trying to do is make a script that will access mysql and grab the logged in users permission lvl such as Admin, Average Member, so on so forth, But the problem is i cant figure out how to grab a specific members. OR i dont grab it at all Zzzz Heres my test script.
PHP Code:
<?
require_once('db_connect.php');
session_start();
$get_user = mysql_query("SELECT * FROM `members` WHERE username = '".$_SESSION['username']."' AND
user_password = '".md5($_SESSION['password'])."'");
$dat = mysql_fetch_assoc($get_user);
echo $dat['permission'];
echo "Logged in 2";
?>
Re: [PHP]Reciving Specific Information From MySQL
PHP Code:
<?
require_once('db_connect.php');
session_start();
$get_user = mysql_query("SELECT username,permission FROM `members` WHERE username = '".$_SESSION['username']."' AND user_password = '".md5($_SESSION['password'])."' LIMIT 1");
$dat = mysql_fetch_assoc($get_user);
echo $dat['permission'];
echo "Logged in 2";
?>
although you might wanna check the username first for mysql injection.
password is fine since its a md5 hash.
i only added LIMIT 1 so it will only search for 1 result and then stop looking.
and dont use * when you only need example 2 values from 10.
like only username,permission while you got id username password permission email etc etc.
Re: [PHP]Reciving Specific Information From MySQL
Tyvm did exactly what i was wantin xD i didnt know you could select certain things(thought the * was a must have)