----------------------------------- JHanson90 Mon May 31, 2004 12:10 pm User Login ----------------------------------- I'm making a site with user login but not with a MySQL database. I'm just using sessions. How do I make it so that an if statement accepts different users? Because right now it's like if($HTTP_SESSION_VARS['username'] == $webmaster['username'] && $HTTP_SESSION_VARS['password'] == $webmaster['password']) { include('membersarea.php'); } else { include('error.php'); } but I want it so that it will also accept other usernames and passwords, like instead of just being if session username == webmaster's username and session password == webmaster's password, I want it so that it could be like if session username == webmaster's username, friend's username, or some other Joe Schmoe's username and session password == webmaster's password, friend's password, or some other Joe Schmoe's password then include membersarea.php Get what I mean? But I don't want to use an elseif for every single user. THen I'd have to include the same file for every single user. TOo much work :( ----------------------------------- PaddyLong Tue Jun 01, 2004 5:32 pm ----------------------------------- easiest would probably be to have all your logins and passwords in an array users[0]="webmaster"; pass[0]="webmaster's password"; users[1]="friend"; pass[1]="friend's password"; and then use a for loop of some sort to check each... $loggedin=false; for ($i = 0; $i < 2; $i++) { if($HTTP_SESSION_VARS['username'] == $users[$i] && $HTTP_SESSION_VARS['password'] == $pass[$i]) { $loggedin = true; } } if($loggedin) { include('membersarea.php'); } else {include('error.php'); } ----------------------------------- Homer_simpson Wed Jun 02, 2004 8:50 am ----------------------------------- it's easier if you just query this to your database and send username and password(encrypted) in pages in sessions : "Select * from users WHERE username='"$_SESSION['username']"'"; ----------------------------------- Blade Wed Jun 02, 2004 2:58 pm Re: User Login ----------------------------------- I'm making a site with user login but not with a MySQL database. I'm just using sessions. ... he clearly said he is not using a database... ----------------------------------- JHanson90 Wed Jun 02, 2004 4:23 pm ----------------------------------- I'm really pissed! I worked for hours trying to set it up so that the multiple user login works, using PaddyLong's post. I eventually got it working for me. Then I told my friend to login, and it didn't work for him *anger/frustration level gets a little higher*. So I keep thinking "how?" then I get the idea to try it on Internet Explorer, instead of Mozilla, what I was using. Guess what? It doesn't work on Internet Explorer. So how the heck am I supposed to change the coding around so it works on both???????!!!!!!!!! ----------------------------------- PaddyLong Wed Jun 02, 2004 10:48 pm ----------------------------------- uhh PHP is server side and browser shouldn't make a difference ... unless there's something screwy with your session that code was mostly just to use as a guide... although it probably should work (you would of course have to put the $ in front of your user and password declarations though) ----------------------------------- Blade Thu Jun 03, 2004 5:25 pm ----------------------------------- i dont really know how you are trying to do this... you dont show very much source or anything. you should really try a basic login program because sessions are only really used to move from page to page and have different features appear on each page (as if you were logged in) and transfer variables and such... ----------------------------------- JHanson90 Fri Jun 04, 2004 3:08 pm ----------------------------------- I got the problem fixed. For some reason Mozilla wasnt killing the sessions when I closed the browser, or something like that, and it kept keeping me logged in. But with help from Amailer, I got it all fixed up. But what do you mean by a basic login program? ----------------------------------- Blade Fri Jun 04, 2004 11:08 pm ----------------------------------- uhm.. basic login... i mean with a form to send the vars, and an array to compare to. use an if statement to check to see if they username/pass is in the arrays, if it is display something, if not then display something different... i use it all the time to problem solve... basically cutting out shit that you think could be causing the problem ----------------------------------- octopi Sat Jun 05, 2004 9:56 am ----------------------------------- Or letting your webserver handle it all via htaccess/htpasswd works well...you can get the username that the user is logged in as threw REMOTE_USER variable, and apache handles these simple sessions way better then php does.