0

I have PHP and HTML files on my IIS site and am trying to get the output of a form shown on the same page. The issue I am running into is when I load the HTML page I am seeing the array information show as plain text on that page. I have form action = "" defined. Alternatively, when I have form action = "file.php" defined, I get the desired results, but on a new page. I took a look at the the link here but didn't seem to provide what I am looking for. I tried adding the tags on each line, which helped a bit but am still seeing the array as plain text. Here is what I have:

<form action="" method = "POST">
MAC Address of phone: <input type="text" name="phonemac"><br><br>
<input type="submit" value="Check Phone Status">
</form>

<?php

$host = "server.com";
$username = "*****";
$password = "*****";

$context = 
stream_context_create(array('ssl'=>array('allow_self_signed'=>true)));

$client = new SoapClient("C:\inetpub\wwwroot\PhoneSetup\AXLAPI.wsdl",
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".$host.":8443/axl",
'login'=>$username,
'password'=>$password,
'stream_context'=>$context

));

$response = $client->getPhone(array("name"=>"$_POST[phonemac]"));
$array = json_decode(json_encode($response), true);

echo $array['return']['phone']['description'];echo '<br><br>';
echo $array['return']['phone']['name']; echo;
?>

</body>
</html>
Chad
  • 83
  • 1
  • 7

1 Answers1

0

This

$myArray = json_decode($data, true);
echo $myArray[0]['id']; // Fetches the first ID
echo $myArray[0]['c_name']; // Fetches the first c_name
// ...

I will write a example with your code

$array = json_decode(json_encode($response), true);

echo $array[0]['phone']
echo $array[0]['description'];
echo '</br></br>';
echo $array[0]['phone'];
echo $array[0]['name']; 

your code would be like

<form action="" method = "POST">
MAC Address of phone: <input type="text" name="phonemac"><br><br>
<input type="submit" value="Check Phone Status">
</form>

<?php

$host = "server.com";
$username = "*****";
$password = "*****";

$context = 
stream_context_create(array('ssl'=>array('allow_self_signed'=>true)));

$client = new SoapClient("C:\inetpub\wwwroot\PhoneSetup\AXLAPI.wsdl",
array('trace'=>true,
'exceptions'=>true,
'location'=>"https://".$host.":8443/axl",
'login'=>$username,
'password'=>$password,
'stream_context'=>$context

));

$response = $client->getPhone(array("name"=>"$_POST[phonemac]"));
$array = json_decode(json_encode($response), true);


    echo $array[0]['phone']
    echo $array[0]['description'];
    echo '</br></br>';
    echo $array[0]['phone'];
    echo $array[0]['name']; 
    ?>
<body>
</html>
Otávio Barreto
  • 1,536
  • 3
  • 16
  • 35
  • 1
    Thanks for the suggestions, however the issue begins with the array entry starting with the `array('allow_self_signed'=>true` string in the `$context` variable. Sorry for not clarifying. Running what you proposed yields the same result. – Chad Aug 01 '19 at 02:17
  • Anyone? I updated the form action statement to align with HTML5 standards. – Chad Aug 05 '19 at 15:49