|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
User levels and security
I'm tyring to work out user authentication for php and having levels of access. Logging in I can easily do and I worked out how to do the access levels but the problem is when your logged in on any level you can still access the admin pages if your a guest say if your logged in and know the right url.
So what I would like to know how I can stop this. This is the login script I use, it is probably faulty anyway as it uses the old session_register instead of the new $_SESSION. So any help there would be appreciated. Thanks. PHP Code:
the login form.php <html> <head><title>onfolkestone ::: Login</title> <link href="../includes/layout.css" rel="stylesheet" type="text/css"> </head> <body class="body" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0"> <div style="position:absolute; left:90; top:50;" width="100%" ><table width="100%" > <!--DWLayoutTable--> <tr bgcolor="#000066"> <td width="100%" height="149" valign="top"> <p> <!-- form for customer login --> <form action="login.php?do=login" method="post"> <table border="0" class="forumline"> <?php if (isset($message)) echo "<tr><td colspan='2'>$message </td></tr>"; ?> <tr> <td align=right><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Username</font></b></td> <td><input type="text" name="fusername" size="20" maxsize="20"> </td> </tr> <tr> <td width="120" align="right"><b><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Password</font></b></td> <td><input type="password" name="fpassword" size="20" maxsize="20"></td> </tr> <tr> <td align="center" colspan="2"> <br> <input type="submit" name="log" value="Enter" class="box"></td> </tr> </table> </form></td> </tr> </table> </div> </body> Thanks again. q3 |
|
#2
|
||||
|
||||
|
This seems a pretty verbose way to handle it. Couldn't you consolidate several of your queries into one?
As for applying the auth levels to individual pages, you'll need to add code to restricted pages that checks the session variable authlevel and prints an error or redirects if the user doesn't have it. |
|
#3
|
||||
|
||||
|
I'd also be more cautious with my error messages. If somebody's trying to log in by guessing usernames and passwords and you confirm that they've guessed a valid username, then you've given them half of what they need to get in. I'd suggest more generic error messages.
|
|
#4
|
|||
|
|||
|
I will sort out the error messages when I sort out this authentication. Thanks for the tip though.
ok ive put in the new sessions: PHP Code:
and the session tag i have 2 check pages that i want secure is: PHP Code:
now what is very odd is that it doesnt work. So i echoed the lines and it is reading the right auth level password and user. So I have no idea what is going on. Any ideas? Thanks |
|
#5
|
|||
|
|||
|
dont worry its all sorted i had stuck a ; at the end of a statement that shouldnt of been there.
thanks for all your help |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > User levels and security |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|