Reputation: 51
I am trying to create a system which allows for authorizing a transaction via a Admin ID. I wish to have multiple Admin ID's, to track which user made the transaction.
$txtKnownAdminHash = "c0b71d437b9138ce3c1860b09b8923ebed6f8aeb3db4093458f38300f6f24eaa";
$txtHashedAdminID = hash('sha256', $txtAdminID);
if ($txtKnownAdminHash != $txtHashedAdminID) {
I want to allow for $txtKnownAdminHash to have multiple values, which is then checked.
Thank you for your help in advance
Upvotes: 1
Views: 53
Reputation: 6896
You can store all the Admin IDs in an array.
$txtKnownAdminHash = array("hash1", "hash2", "hash3", "hash4");
To check if the $txtHashedAdminID
is in the array, you can use in_array()
.
This will check if $txtHashedAdminID
is in $txtKnownAdminHash
array:
<?php
if (in_array($txtHashedAdminID, $txtKnownAdminHash)) {
// the hash is in the array
} else {
// the hash is not in the array
}
?>
Read more about:
array()
: http://www.w3schools.com/php/php_arrays.asp.in_array()
: http://www.w3schools.com/php/func_array_in_array.asp.Upvotes: 2