then admin Y page checks if session user and admin is filled
and admin N page checks if session user is filled. The code on those pages are right(i think), but It's probably my method of going about this is wrong.
02-03-2013, 03:26 AM
The first glaring issue I see is that you are using one = instead of two (you need two to compare values, ie. 'is equal to') and you have not put your Y and N in quote marks (as they are not integers), they should be
if ($count > 0) && ($admin == 'Y')
if ($count > 0) && ($admin == 'N')
However I also don't know where your $admin variable is being set and assigned a value so that could also be causing a problem.
02-03-2013, 03:08 PM
and I wish to set the variable durring the query so I can keep track of it. $admin first apears here: AND admin='$admin' (durring the query)
What would be the proper way of going about this?
02-03-2013, 03:19 PM
What you have in your query means that AND admin='The value assigned to the variable $admin', therefore a value has to have been assigned to the variable $admin before you can use it in your query.
However, looking at your query you are actually trying to work out the value of admin stored in the database for the user who is logging in and therefore your query should just be
$sql = "SELECT * FROM $tbl_name WHERE username='$username' AND password='$password' LIMIT 1";