简体   繁体   中英

Adminer Login PHP

I'm manage user logins into Adminer. The PHP code to try to achieve this is below:

<?php
function adminer_object() {

class AdminerSoftware extends Adminer {

    function name() {
      // custom name in title and heading
      return  "<a href='localhost'>My App</a> Admin";;
    }

    function credentials() {
      $DB_USER=$_POST['auth[username]'];
      $DB_PASSWORD=$_POST['auth[password]'];

      // server, username and password for connecting to database
      return array('localhost', $DB_USER, $DB_PASSWORD);
    }
  }

  return new AdminerSoftware;
}
include "./adminer-4.2.3.php";

When I click the login button, I'm taken to the regular page that lists databases but only datatbases which allow guest access are listed. The only way I am able to log in is to replace the return array with hard coded creds.

      return array('localhost', 'user', 'password');

When using this, whether I enter no creds or the 'user' and 'password' values, hitting the login button takes me to a full list of databases.

I suspect there's something very simple which I'm missing.

Thanks.

Try change credentials() function like this:

function credentials() {
    $DB_USER=$_POST['auth']['username'];
    $DB_PASSWORD=$_POST['auth']['password'];

    // server, username and password for connecting to database
    return array('localhost', $DB_USER, $DB_PASSWORD);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM