I'm trying to get POST variables into my $ssh->exec The post variables are not being used in the command.I want $domain and $password to be used within the adduser as below.
I'm running this on a centos 7 server php 7.3 I can echo out variable but i can' t it to be used in the command.
I can echo out $domain and also $password.
An example post was
username:adada.com and Password:passwordwe3
This command with the strings entered worked fine.
set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/html/phpsec');
include ('Net/SSH2.php');
$ssh = new Net_SSH2('hostname');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
$domain = $_POST['domain'];
$password = $_POST['password'];
echo $ssh->exec('adduser $domain -m -p $password -d /var/www/shared/$domain/public_html');
echo $ssh->exec('su $domain');
echo $ssh->exec('pwd');
die();
The error from the form is as follows. adduser: invalid user name '/var/www/shared//public_html' /root