Page 1 of 1
Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 1:08 pm
by fireballgames
Thank you for looking at this thread. I'm having a problem with a user login system, there is a table in my database with Access Levels in it. From a login check (Which works) I want to get the access level and turn it into a cookie to give the user access to different parts of my website. The error I get is that all users, despite different access levels, get turned into "Users".
I believe I've gone wrong in this one part of code:
Code: Select all
[color=#40FF00]//Access Levels---------------[/color]
$sql1="SELECT Level_access, Username, Password FROM $tbl_name WHERE Username='$Username' and Password='$Password'";
$reesult=mysql_query($sql1);
if($reesult==2){
setcookie("admin", $Username, time()+3600);
}
elseif($reesult1==1){
setcookie("donator", $Username, time()+3600);
}
else{
setcookie("user", $Username, time()+3600);
}
Thanks again for reading.
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 1:18 pm
by jaoudestudios
I think you are over complaining the matter.
Using sessions would be easier.
When the user logs in get the user level/role then and just keep checking that.
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 1:59 pm
by fireballgames
I did try sessions but they didn't stay. I wasn't able to access my exclusive pages.
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 2:02 pm
by mmj
[quote]
Code: Select all
$seql="SELECT Level_access FROM $tbl_name WHERE Username='$Username' and Password='$Password'";
$reesult=mysql_query($sql1);
[quote]
Unless you set $sql1 in a different location thats your problem.
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 2:07 pm
by fireballgames
Thanks, that isn't the problem though

Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 3:23 pm
by wasir
try this...
Code: Select all
$seql="SELECT Level_access, Username, Password FROM $tbl_name WHERE Username='$Username' and Password='$Password'";
$reesult=mysql_query($sql1);
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 3:30 pm
by paul00
Or better this
Code: Select all
$sql1="SELECT Level_access, Username, Password FROM $tbl_name WHERE Username='$Username' and Password='$Password'";
$reesult=mysql_query($sql1);
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 3:51 pm
by fireballgames
Nope, still the same

Thank you very much for attempting though
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 3:56 pm
by jaoudestudios
Did you have session_start() on your exclusive page?
You have no protection on your mysql queries from injection!
Post your database schema, then we can see what is wrong with the query - remember it is case sensitive.
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 4:41 pm
by fireballgames
http://pastebin.ca/1291049 - My whole checklogin file
and how do I get a schema of the database from PHPMyAdmin?
Re: Can anyone see a problem with this? - Newb Question
Posted: Sun Dec 21, 2008 4:49 pm
by fireballgames
Infact - Close this plz :p I've seen another login script with exactly what I want:
http://www.evolt.org/PHP-Login-System-w ... n-Features