Nucleus Posted February 7, 2016 Share Posted February 7, 2016 I am using the below to sent ssh commands through a web interface. For example, to get the hostname of a Linux computer: index.html <form action="phpseclib/hostname.php" method="get" target="_blank"> <select name="clients"> <option value="SelectClient">Select Client</option> <option value="192.168.0.51">Client001</option> <option value="192.168.0.52">Client002</option> <option value="192.168.0.53">Client003</option> </select> <input type='submit' /> </form> hostname.php <?php include('Net/SSH2.php'); include('variables.php'); $ip = $_GET['clients']; $ssh = new Net_SSH2('$ip'); if (!$ssh->login($user, $pass)) {exit('Login Failed');} echo $ssh->exec('hostname'); ?> In hostname.php if I set the $ip variable manually, everything works as expected. But when I use $ip = $_GET['clients']; I get a message saying "Login Failed" When I echo $ip I correctly get the IP Address of the dropdown selection. What I'm I doing wrong here? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/300747-set-variable-from-dropdown-menu/ Share on other sites More sharing options...
Solution Nucleus Posted February 7, 2016 Author Solution Share Posted February 7, 2016 This fixed it <?php include('Net/SSH2.php'); include('variables.php'); $ip = $_GET['clients']; $ssh = new Net_SSH2($ip); if (!$ssh->login($user, $pass)) {exit('Login Failed');} echo $ssh->exec('hostname'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/300747-set-variable-from-dropdown-menu/#findComment-1530831 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.