PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi guys im new to the world of php however i have produced a login script which is below. What i want the script to do is first of all check if a user exits? Check if they are validated?Check the rank which the user has? The problem is it logins in fine however it bypasses the two checks in my script. My understanding is that we first of all get the info needed out of the database i.e
if ($_SESSION['rank'] = '2'){
Header ("Location: admin.php");
exit;
}
Full code is below and any help would be much appriacted? Also once i type in the url for login3.php page it re-directs be to another page 'login.php' which was an earlier attempt not sure why that is any help on that would be appriacted?
Have you initiated a session somewhere? Add session_start(); to the start of the file so the session data is actually stored, and can be passed to other pages.
Just skimmed over the code quickly but one problem you have here is in the above example, rather than comparing $_SESSION['rank'] to 2, you are assigning the value of 2 to it.
thanks i believe that will work however i still get the second error which it doesn't load the login3.php when i type in the url it goes to another script?Not sure why? Script is edited and now is below:
It redirects to login.php which is on my server this was an earlier script i tried. i took that off the server and it still tries and find it to no success. There doesn't seem to be a problem with cookies in the browser it's in the code im sure just can't see it. what you reckon?
many thanks i'v sorted out some of the major problems just got one more problem which im trying to sort out myself, if i can't i'll post it on the board. cheers
Are all those if statements exclusive? If not, try putting them in order of priority and using elseifs... You may be running into issues with the script producing output and then trying to redirect with the header() (which it can't after output has started), so put the if clauses with header statements before and clauses that produce output.