Jump to content

array data from form not working...


htakeuchi

Recommended Posts

Hello... I would like to ask for your expert opinion.

 

I have created a small web form that will send some information via ssh2_exec() to a number of units on the filed through my WAN.

 

I created a Web form, where I request the name of the units to be sent this information to separated by a comma, and this information then is setup as the array() in the php.

 

But I am guessing that the _GET or the _POST is adding some character I cannot see to the names which causes the array to fail wen I perform the foreach()...

 

Here is the small section of code I am using...

 

 

----------------------------------

 

<?php
$nodes = $_POST['nodes'];
$script = $_POST['script'];
$hosts = array($nodes);
foreach ($hosts as $host) {
$hostname = $host;
$url = 'ltf'.$host.'.domain.com';
$con =@ssh2_connect($url, 22);
echo $nodes;
if(!($con)){
echo 'Unable to to execute connection to Remote Unit<br>';
exit(1);
}
if (!@ssh2_auth_password($con, 'admin' , 'password')){
echo 'Failed to Authenticate to Remote Unit!';
exit(1);
}
elseif (!(ssh2_exec($con, '$script'))){
echo 'Command was not executed correctly<br>';
}
echo "Connection to ".$host." was successful!<br>";
};
?>
 
 
Thank you so much in advance!
 
 
HT
Link to comment
https://forums.phpfreaks.com/topic/275611-array-data-from-form-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.