# storing user credentials in array configuration help!

**URL:** <https://www.phphelp.com/t/storing-user-credentials-in-array-configuration-help/13775>\
**Category:** Comments and Questions\
**Created:** [July 8, 2011, 12:07am UTC](https://www.phphelp.com/t/storing-user-credentials-in-array-configuration-help/13775 "2011-07-08T00:07:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![subless](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subless](https://www.phphelp.com/u/subless)\
**Post date:** [July 8, 2011, 12:07am UTC](https://www.phphelp.com/t/storing-user-credentials-in-array-configuration-help/13775/1 "2011-07-08T00:07:24Z")

</div>

I’ve searched google plenty of times and have only found one tutorial but can’t get it working right, so I figured I would ask here.

Instead of allowing users to register for an account, I want to store user credentials in an array and search the array for the correct username corresponding with the correct password.

I need help though cause I cannot seem to figure it out. I would like it to look something like the below example:

[php]\<?php

// Username and Password arrays  
$username = array();  
$password = array();

// Usernames  
$username[1] = “demo”;  
$username[2] = “admin”;  
$username[3] = “test”;

// Passwords  
$password[1] = “playme”;  
$password[2] = “hello”;  
$password[3] = “tester”;

?\>[/php]

Now using a form how can I check to make sure that $username[1] is compared to $password[1] and that the submitted values are correct?

Thanks, hope I didn’t confuse anyone.

---

<div class="post-metadata">

**Author:** ![plintu](https://www.phphelp.com/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@plintu](https://www.phphelp.com/u/plintu)\
**Post date:** [July 8, 2011, 1:30am UTC](https://www.phphelp.com/t/storing-user-credentials-in-array-configuration-help/13775/2 "2011-07-08T01:30:03Z")

</div>

[php]

\<? $username = array('demo'=\>'playme', 'admin'=\>'hello', 'test'=\>'tester'); if($\_REQUEST['username']){ $x=$\_REQUEST['username']; $pass=$\_REQUEST['password']; if($username[$x]==$pass){ echo"Success!"; }else{ echo"fail!"; } } ?\>

[/php]

---

<div class="post-metadata">

**Author:** ![subless](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@subless](https://www.phphelp.com/u/subless)\
**Post date:** [July 8, 2011, 2:34am UTC](https://www.phphelp.com/t/storing-user-credentials-in-array-configuration-help/13775/3 "2011-07-08T02:34:32Z")

</div>

Works like a charm! Thanks for your help.
