Create Database API – DirectAdmin PHP
Create Database using DirectAdmin PHP API. If you are working with separate VPS and installed DirectAdmin as your cpanel software and you want to create database and user with help of API for further user sales. You need this support to move on. Let’s see the API Functionality to start programming it.
DirectAdmin PHP API Code
<?php include 'httpsocket.php'; $sock = new HTTPSocket; $sock->connect('127.0.0.1',2222); //Your Server IP address $sock->set_login("user","pass"); $sock->set_method('POST'); $sock->query('/CMD_API_DATABASES', array( 'action' => 'create', 'name' => "kvcodestestdb2", 'user' => "MainUser", 'passwd' => "Kvcodes@com", 'passwd2' => "Kvcodes@com", )); $result = $sock->fetch_body(); echo $result; ?>
If you want to create database with existing user, the array should be like this.
array( 'action' => 'create', 'name' => "kvcodestestdb2", 'userlist' => "MainUser", 'passwd' => "Kvcodes@com", 'passwd2' => "Kvcodes@com", )
Everytime, when you create database we can create new user for each database. If you want downloadable code, you can get it here.