2

i trying to create new database on my shared web hosting with directAdmin web control API. i use below code to connect to directAdmin and create database but when i open php script, it not logged in to direct admin and showing login page .

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('xx.xx.xx.xx',2222);

$user = getenv('xxxxxxx');
$pass = getenv('xxxxxxx');

$sock->set_login("${user}","${pass}");

$sock->set_method('POST');

$sock->query('/CMD_API_DATABASES',
       array(
            'action' => 'create',
            'name' => "Test101",
            'user' => "dbuser",
            'passwd' => "$pass",
            'passwd2' => "$pass",
));

$result = $sock->fetch_body();

echo $result;
Blaster
  • 135
  • 3
  • 16

0 Answers0