I pulled usernames and passwords from database, and they match, I can pass the login page. But I want to restrict some access to users, and provide access to admins, i do this with field admin in database. admin is int, and can have values 1 and 0. This code always enters else barnch of this if ($result == '1').
It is truly annoying, can you provide some clues?
$sql="SELECT admin FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
if(mysql_num_rows($result) == 1) {
$_SESSION['username'] = $_POST['username'];
if ($result == '1'){
echo "uspeh admine";
}else{
echo "uspeh korisnice";
}
}else{
echo "neuspeh";
}
$resultis a the resource for the results. You need to usemysql_fetch_assoc()or similar.