Jump to content

set variable(s) from checkboxes - display multiple results


Nucleus

Recommended Posts

I am using the below to sent ssh commands through a web interface. Below is an example to get the hostname of a Linux computer.
 
I need to change this form, from a dropdown menu, to checkboxes. I know how to do this in html, but I don't know how to tell php to handle it. Reason is, what if multiple checkboxes are selected? how would  target="main" display results from multiple computers?
 
index.html
 <form action="phpseclib/hostname.php" method="get" target="main">
      <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');
  ?>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.