htakeuchi Posted March 13, 2013 Share Posted March 13, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/275611-array-data-from-form-not-working/ Share on other sites More sharing options...
Barand Posted March 13, 2013 Share Posted March 13, 2013 Use this to check exactly what was POSTed echo '<pre>',print_r($_POST, true),'</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/275611-array-data-from-form-not-working/#findComment-1418414 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.