Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End [Solved] User Authentication (without db)

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #29611
    Makeshift
    Member

    Hey guys, I setup a page to input information into a database, but to do so, the page is password protected, and each user has an authentication password which goes through a salted hash. What I wanted to do is keep the variables in php (because I don’t know how to do it with a database) with something like this..

    Code:
    $user_authentication = array(
    ‘users’ => array(
    ‘dyllon’ => ‘foo’,
    ‘robb’ => ‘bar’
    )
    );

    So if the user types in foo to authenticate, it returns that dyllon has inserted information into the table, and if bar is used, it returns that robb did.

    Is there a way I can search the array for the specified value, as well as return it’s key?

    #79715
    Makeshift
    Member

    Nevermind, I got it.

    This is the final code I came up with:

    Code:
    $authentication = $_POST[’authentication’];
    $user_authentication = array(
    ‘users’ => array(
    ‘dyllon’ => ‘foo’,
    ‘robb’ => ‘bar’
    )
    );

    foreach($user_authentication as $key){
    foreach($key as $key => $val){
    if($authentication == $val){
    echo $key;
    }
    }
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.