tags:

views:

22

answers:

1

in a PHP web page i need to run this following command to create a new domain:

virtualmin create-domain --domain DOMAIN --pass PASS --plan 'Standard Package' --limits-from-plan --features-from-plan

This is usually executed in a shell but i don't know how to do it from a web page and also i need to take the domain string and pass string from a web form. Can anyone help with the PHP code as my skills are basic and i have already tried a few things that just don't work.

Thanks.

A: 

How about shell_exec() ?:

shell_exec("virtualmin create-domain --domain DOMAIN (...)");

or the backtick operator:

`virtualmin create-domain --domain DOMAIN (...)`

You can access parameters submitted via a HTML form with the $_POST array. But make sure to validate the user input. I suggest to read a tutorial about this.

Felix Kling
i have tried this and will not work, i'm using php else where on my server but this one command will not work<html><body><?shell_exec("mkdir hello");?></body></html>
David Maitland
@David Maitland: Is safe mode enabled? If so, the exec commands might not work. You can search on SO for this issue. E.g. http://stackoverflow.com/search?q=php+execute+shell+command
Felix Kling
no its turned off just checked in the php.ini files and in virtualmin PHP configuration
David Maitland