Hi I am unable to get the data from my html form.I need to know firstly how to get data correctly from html forms. Secondly why this is not working? I need to get the value "IBM" when I click "IBM Quote".
<!DOCTYPE html>
<html>
<head>
<title>Stock Quote</title>
</head>
<body>
<form action="soapTest.php" method="post">
<button name="IBM" type="submit">IBM Quote</button>
</form>
</body>
</html>
Php Code
<?php
$wsdl = "http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl";
$client = new SoapClient($wsdl);
$stock = $_POST["button"];
print $stock;
$parameters= array("request"=>$stock);
$values = $client->GetStockQuote($parameters);
$xml = $values->GetStockQuoteResult;
$currentprice = $xml->Last;
$volume=$xml->Volume;
$percentageChange=$xml->PercentageChange;
if($volume!=null)
print "<br />\n Volume: $volume";
else
print "Volume not set";
if($percentageChange!=null)
print "<br />\n PercentageChange: $percentageChange";
else
print "percentageChange not set";
?>
Output:
Notice: Undefined index: button in /Applications/XAMPP/xamppfiles/htdocs/soapTest.php on line 6
Fatal error: Uncaught SoapFault exception: [a:InternalServiceFault] Object reference not set to an instance of an object. in /Applications/XAMPP/xamppfiles/htdocs/soapTest.php:9 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/soapTest.php(9): SoapClient->__call('GetStockQuote', Array) #1 /Applications/XAMPP/xamppfiles/htdocs/soapTest.php(9): SoapClient->GetStockQuote(Array) #2 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/soapTest.php on line 9