jrthor2
03-03-2004, 09:02 AM
I have a page that is making a SOAP call to a webservice to get stock prices. I have a field where you can enter the company symbol, but when I submit the page, my variable for $symbol is blank. My input field is named symbol. Below is my code. This is on a Windows box with PHP 4.3.3.
<?
$symbol = "";
require_once('inc/nusoap.php');
$soapclient = new soapclient('http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl',1);
echo "Symbol " . $symbol;
if (!$symbol) {
$rite_aid = $soapclient->call('getQuote',array('symbol'=>'rad'));
$ibm = $soapclient->call('getQuote',array('symbol'=>'ibm'));
$cvs = $soapclient->call('getQuote',array('symbol'=>'cvs'));
$wag = $soapclient->call('getQuote',array('symbol'=>'wag'));
$hershey = $soapclient->call('getQuote',array('symbol'=>'hsy'));
} else {
$results = $soapclient->call('getQuote',array('symbol'=>'$symbol'));
}
?>
<html>
<head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td colspan="2" nowrap><strong>Stock Prices using PHP NUSoap Webservice </strong></td>
</tr>
<? if (!$symbol) {?>
<tr>
<td width="5%" nowrap>Rite Aid</td>
<td width="95%"><?=$rite_aid?></td>
</tr>
<tr>
<td nowrap>Walgreens</td>
<td><?=$wag?></td>
</tr>
<tr>
<td nowrap>CVS</td>
<td><?=$cvs?></td>
</tr>
<tr>
<td nowrap>IBM</td>
<td><?=$ibm?></td>
</tr>
<tr>
<td nowrap>Hershey Foods</td>
<td><?=$hershey?></td>
</tr>
<? } else {?>
<tr>
<td>
<?=$symbol?>
</td>
<td>
<?=$results?>
</td>
</tr>
<? } ?>
<tr valign="top">
<td nowrap>Enter symbol: </td>
<td>
<form name="stocks" method="get" action="webservice_stocks.php">
<input name="symbol" type="text" id="symbol">
<input type="submit" name="Submit" value="Get Stock Price">
</form> </td>
</tr>
</table>
</body>
</head>
</html>
<?
$symbol = "";
require_once('inc/nusoap.php');
$soapclient = new soapclient('http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl',1);
echo "Symbol " . $symbol;
if (!$symbol) {
$rite_aid = $soapclient->call('getQuote',array('symbol'=>'rad'));
$ibm = $soapclient->call('getQuote',array('symbol'=>'ibm'));
$cvs = $soapclient->call('getQuote',array('symbol'=>'cvs'));
$wag = $soapclient->call('getQuote',array('symbol'=>'wag'));
$hershey = $soapclient->call('getQuote',array('symbol'=>'hsy'));
} else {
$results = $soapclient->call('getQuote',array('symbol'=>'$symbol'));
}
?>
<html>
<head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tr>
<td colspan="2" nowrap><strong>Stock Prices using PHP NUSoap Webservice </strong></td>
</tr>
<? if (!$symbol) {?>
<tr>
<td width="5%" nowrap>Rite Aid</td>
<td width="95%"><?=$rite_aid?></td>
</tr>
<tr>
<td nowrap>Walgreens</td>
<td><?=$wag?></td>
</tr>
<tr>
<td nowrap>CVS</td>
<td><?=$cvs?></td>
</tr>
<tr>
<td nowrap>IBM</td>
<td><?=$ibm?></td>
</tr>
<tr>
<td nowrap>Hershey Foods</td>
<td><?=$hershey?></td>
</tr>
<? } else {?>
<tr>
<td>
<?=$symbol?>
</td>
<td>
<?=$results?>
</td>
</tr>
<? } ?>
<tr valign="top">
<td nowrap>Enter symbol: </td>
<td>
<form name="stocks" method="get" action="webservice_stocks.php">
<input name="symbol" type="text" id="symbol">
<input type="submit" name="Submit" value="Get Stock Price">
</form> </td>
</tr>
</table>
</body>
</head>
</html>