rofl90 Posted February 17, 2008 Share Posted February 17, 2008 $username = 'charlie, andreas'; As I've written a script of which is a user login, I now have a partner and am having troubles adding him as a user, as I was trying to code it without MySQL for fun.. if not I guess I should get converting it to mysql, it's currently held in variables with a random word md5'd for security. Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Yes, you can very easily explode that to get it into an array: <?php $username = 'charlie,andreas'; $users = explode(",", $username); print_r($users); //should returrn Array( [0] = charlie [1] = andreas ) ?> Quote Link to comment Share on other sites More sharing options...
rofl90 Posted February 17, 2008 Author Share Posted February 17, 2008 Nice - thanks man!! Quote Link to comment Share on other sites More sharing options...
rofl90 Posted February 17, 2008 Author Share Posted February 17, 2008 Hmm, doesn't seem to be working it prints the correct array, but it doesn't seem to like it in the usernames. It doesn't let me login with either of the usernames. I basically want it to turn out as $username = 'charlie'; $username = 'andreas'; so when it checks to see if the username entered = the correct username it's identified as == is correct. Just echoing $username returns 'Array' Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Yeah, It's an array.. $username['0'] = 'charlie'; $username['1'] = 'andreas'; Quote Link to comment Share on other sites More sharing options...
rofl90 Posted February 17, 2008 Author Share Posted February 17, 2008 but my original system only checks $username not $username[0] $username[1] Is there anyway to get around that or do I need to recode my system ;/ lol Quote Link to comment Share on other sites More sharing options...
Stooney Posted February 17, 2008 Share Posted February 17, 2008 The most basic work around would probably be this. $username=array('charlie', 'andreas'); then instead of if($input==$username) use if(in_array($input, $username)){ Basically it will check if the user input username is in the array you made. Hope that makes sense. Quote Link to comment Share on other sites More sharing options...
rofl90 Posted February 17, 2008 Author Share Posted February 17, 2008 Thanks it worked! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.