Add 'php/phpxmlrpc/' from commit 'cd5dbb4a511e7a616a61187a5de1a611a9748cbd'
[plcapi.git] / php / phpxmlrpc / demo / client / getstatename.php
1 <html>
2 <head><title>xmlrpc - Getstatename demo</title></head>
3 <body>
4 <h1>Getstatename demo</h1>
5
6 <h2>Send a U.S. state number to the server and get back the state name</h2>
7
8 <h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3>
9 <?php
10
11 include_once __DIR__ . "/../../src/Autoloader.php";
12 PhpXmlRpc\Autoloader::register();
13
14 if (isset($_POST["stateno"]) && $_POST["stateno"] != "") {
15     $stateNo = (integer)$_POST["stateno"];
16     $encoder = new PhpXmlRpc\Encoder();
17     $req = new PhpXmlRpc\Request('examples.getStateName',
18         array($encoder->encode($stateNo))
19     );
20     print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n";
21     $client = new PhpXmlRpc\Client("http://phpxmlrpc.sourceforge.net/server.php");
22     $client->setDebug(1);
23     $r = $client->send($req);
24     if (!$r->faultCode()) {
25         $v = $r->value();
26         print "<br/>State number <b>" . $stateNo . "</b> is <b>"
27             . htmlspecialchars($encoder->decode($v)) . "</b><br/>";
28     } else {
29         print "An error occurred: ";
30         print "Code: " . htmlspecialchars($r->faultCode())
31             . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
32     }
33 } else {
34     $stateNo = "";
35 }
36
37 print "<form action=\"getstatename.php\" method=\"POST\">
38 <input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>
39 <p>Enter a state number to query its name</p>";
40
41 ?>
42 </body>
43 </html>