storing user credentials in array configuration help!

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.

[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]

Works like a charm! Thanks for your help.

Sponsor our Newsletter | Privacy Policy | Terms of Service