I am just working with username-to-password validation scripting, and I don't want to mess with database connections just yet. So I'm just putting certain test emails and passwords into some arrays, then working at validating against those arrays.
I'm getting stuck on the best way to do this, because I actually want to put more pertinent data into each "user" array.
Here's what I've started so far, and you'll see what I'm shooting for:
<?php
$email = $_POST['email'];
// test emails
$logins = array('[email protected]'=>'123456','[email protected]'=>'123456');
if (!array_key_exists($email, $logins)) {
echo "that email does not exist, stop here.";
}else{
echo "email exists, continue...";
}
?>
And this works fine, since it's simple, but as I needed to add more options into the array, the method changed to this:
<?php
// tester accounts
$user1 = array('email'=>'[email protected]','password'=>'123456','fullname'=>'john smith','handle'=>'johnny');
$user2 = array('email'=>'[email protected]','password'=>'123456','fullname'=>'Jane Smith','handle'=>'janeyS');
// credentials passed from a form
$email = $_POST['email'];
$pass = $_POST['pass'];
/* not quite sure how to validate the $user arrays */
?>
And the user arrays probably will grow with more things related to that user, obviously. But I'm used to working with database connections, and not straight from PHP arrays.
Can someone throw me a little advice on a simple email/pass validation from multiple php arrays like what I just did above? Or perhaps there's a better method?