1

我正在管理用户登录到Adminer。尝试实现此目的的 PHP 代码如下:

<?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";

当我单击登录按钮时,我会进入列出数据库的常规页面,但只列出允许访客访问的数据库。我能够登录的唯一方法是用硬编码的凭据替换返回数组。

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

使用此功能时,无论我不输入凭据还是输入“用户”和“密码”值,点击登录按钮都会将我带到完整的数据库列表。

我怀疑我缺少一些非常简单的东西。

谢谢。

4

1 回答 1

0

尝试像这样更改凭据()函数:

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);
}
于 2021-12-16T15:33:25.707 回答