0

My issue is that I cant login with this because for some reason it dont let me, if I have the code getting the data from the database it dont work (I have a clear connection and connects just fine)

    <?php
$steamauth['apikey'] = APIKEY; // Your Steam WebAPI-Key found at http://steamcommunity.com/dev/apikey
$steamauth['domainname'] = WEBSITE; // The main URL of your website displayed in the login page
$steamauth['logoutpage'] = WEBSITE; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
$steamauth['loginpage'] = WEBSITE; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!

// System stuff
if (empty($steamauth['apikey'])) {die("<div style='display: block; width: 100%; background-color: red; text-align: center;'>SteamAuth:<br>Please supply an API-Key!<br>Find this in steamauth/SteamConfig.php, Find the '<b>\$steamauth['apikey']</b>' Array. </div>");}
if (empty($steamauth['domainname'])) {$steamauth['domainname'] = $_SERVER['SERVER_NAME'];}
if (empty($steamauth['logoutpage'])) {$steamauth['logoutpage'] = $_SERVER['PHP_SELF'];}
if (empty($steamauth['loginpage'])) {$steamauth['loginpage'] = $_SERVER['PHP_SELF'];}

$steamid=mysqli_connect("","","","");
$steamid->set_charset("utf8");
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($steamid, "SELECT * FROM panel_admins");

if (!$result) {
    printf("Error: %s\n", mysqli_error($steamid));
    exit();
}

echo "";

while ($row = mysqli_fetch_array($result)) {

$allowed_ids = [
    '"' . $row['steamid'] . '"',
];

}

mysqli_close($steamid);
?>

But on the other hand if I have my code like this, I can login with no problem

<?php
$steamauth['apikey'] = APIKEY; // Your Steam WebAPI-Key found at http://steamcommunity.com/dev/apikey
$steamauth['domainname'] = WEBSITE; // The main URL of your website displayed in the login page
$steamauth['logoutpage'] = WEBSITE; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
$steamauth['loginpage'] = WEBSITE; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!

// System stuff
if (empty($steamauth['apikey'])) {die("<div style='display: block; width: 100%; background-color: red; text-align: center;'>SteamAuth:<br>Please supply an API-Key!<br>Find this in steamauth/SteamConfig.php, Find the '<b>\$steamauth['apikey']</b>' Array. </div>");}
if (empty($steamauth['domainname'])) {$steamauth['domainname'] = $_SERVER['SERVER_NAME'];}
if (empty($steamauth['logoutpage'])) {$steamauth['logoutpage'] = $_SERVER['PHP_SELF'];}
if (empty($steamauth['loginpage'])) {$steamauth['loginpage'] = $_SERVER['PHP_SELF'];}

// allow only these ids
$allowed_ids = [
    'steamid64here',
];
?>

Maybe the code is not good or something. Im using PHP 5.6! What I want with this code? I want to in the steamid column it will grab the steamid64 and put there.

1 Answer 1

1

You are overwriting the value of $allowed_ids in while loop in each pass.

Try the code below:

   $allowed_ids = array(); // initializing array
   while ($row = mysqli_fetch_array($result)) {
         $allowed_ids[] = $row['steamid'] ;// inserting elements into the array
   }
Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome. Please see if you can upvote the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.