In my project I have a HTML form
that is included in my Php
file.
The HTML file has some JavaScript
methods to fill automatically, anyways.
In first step The Php
connect to a remote device via SSH
and run some commands.
The Php
has a class
and some functions
,
In my next step I should read the data that had inserted in the remote device via SSH
and fill out in HTML
form.
I can read the data, and can display it via echo
. ( as you will see here )
But how can I display that value into my HTML
input type value?
Here is my HTML code : ( I write it briefly, cause it is too long and no need to write all)
<div id="linkname" >
<label>Wireless Link Name</label>
<input type="text" name="ssid" id="ssid"><br>
</div>
Here is my Php
File class and methods :
<?php
class SSHCommand{
public $ssh;
include('./view/config.html');
include('Net/SSH2.php');
class SSHCommand{
public function display(){
session_start();
$username=$_SESSION['username'];
$password=$_SESSION['password'];
$ip=$_SESSION['ip'];
$this->ssh=new Net_SSH2($ip);
if($this->ssh->login($username, $password)) {
$my_array= explode("
", $this->ssh->exec('some command'));
foreach($my_array as $cat) {
if(strpos($cat, "name=") !== false) {
// I should here insert the $cat value into ssid input
break;
} else {
// Do nothing
}
}
} else echo 'wrong';
}
}
$sshCommand=new SSHCommand();
$sshCommand->display();
?>
As you see I fill an array
, I search for a specific text in the array, like
name=
, and want insert that value into the input type ssid
.
How can I do that in Php code? Any Idea?