Below I have a simple key system I am trying to do to only allow certain people to use my little API I am building for my site. I want to give out a random 10 character key to users, I would like to not store it in a database because that would just be another additional query made to my database.
So below you see how I have it set up, a simple array and a key value, it check if key is in array, what I would like to do is in the array, store a users name and ID number
so array has
key - name- id
key - name -id
key - name -id
key - name -id
But only key will be checked with
if (in_array($key, $keyarray)) {
Any ideas how to do this, I would then like to build a page that would show the keys array in a table like
Name - key - ID
Jason - dfsdf - 34
<?PHP
$key = (!empty($_GET['key'])) ? $_GET['key']:null;
$keyarray = array('fsadfasdfg','fsdfdfsdfs','ghlsdjkdfg');
//see if key is valid
if (in_array($key, $keyarray)) {
//key is valid so do stuff
//
///
///
//
//
}else{
echo 'Not a Valid Key';
}
?>