Reputation: 500
I am trying to create a PHP script which has a HTML form included within it. Please help me edit this:
$SoapClient = new SoapClient ( NULL, $options );
try {
$cities = $SoapClient->getCities ();
// echo var_dump($SoapClient->getCities ());
echo "<form action= " . "'$" . "PHP_SELF' method = 'post'>";
echo "<h4>Choose Origin</h4>";
foreach ( $cities as $city ) {
echo "<input type='radio' name = 'origin' value = " . $city . "> <br>";
}
echo "<h4>Choose Destination</h4>";
foreach ( $cities as $city ) {
echo "<input type='radio' name = 'destination' value = " . $city . "> <br>";
}
echo "<p>";
echo "<input type='submit' name='submitButton' value='Calculate Great Circle'>";
// show soap request and response
} catch ( Exception $e ) {
echo "<h3>SOAP error</h3><pre>" . $e . "</pre>";
echo "<h3>SOAP error last response</h3><pre>" . $SoapClient->__getLastResponse () . "</pre>";
echo "<h3>SOAP error last request</h3><pre>" . $SoapClient->__getLastRequest () . "</pre>";
}
Thanks a lot :)
Upvotes: 0
Views: 67
Reputation: 3031
You want to display the cities names next to your radios, try this in your two loops :
foreach ( $cities as $city ) {
echo "<label><input type='radio' name='origin' value='" . $city . "'>" . $city . "</label> <br>";
}
And also replace
echo "<form action= " . "'$" . "PHP_SELF' method = 'post'>";
by
echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
Upvotes: 1