Jump to content

Is it possible to store two things in a variable eg......


rofl90

Recommended Posts

$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.

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.