1 <?php require_once __DIR__ . "/_prepend.php"; ?><html lang="en">
2 <head><title>xmlrpc - Getstatename demo</title></head>
4 <h1>Getstatename demo</h1>
6 <h2>Send a U.S. state number to the server and get back the state name</h2>
8 <h3>The code demonstrates usage of automatic encoding/decoding of php variables into xmlrpc values</h3>
10 <p>You can see the source to this page here: <a href="getstatename.php?showSource=1">getstatename.php</a></p>
13 if (isset($_POST["stateno"]) && $_POST["stateno"] != "") {
14 $stateNo = (integer)$_POST["stateno"];
15 $encoder = new PhpXmlRpc\Encoder();
16 $req = new PhpXmlRpc\Request('examples.getStateName',
17 array($encoder->encode($stateNo))
19 print "Sending the following request:<pre>\n\n" . htmlentities($req->serialize()) . "\n\n</pre>Debug info of server data follows...\n\n";
20 $client = new PhpXmlRpc\Client(XMLRPCSERVER);
22 $r = $client->send($req);
23 if (!$r->faultCode()) {
25 print "<br/>State number <b>" . $stateNo . "</b> is <b>"
26 . htmlspecialchars($encoder->decode($v)) . "</b><br/><br/>";
28 print "An error occurred: ";
29 print "Code: " . htmlspecialchars($r->faultCode())
30 . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
36 print "<form action=\"getstatename.php\" method=\"POST\">
37 <input name=\"stateno\" value=\"" . $stateNo . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>
38 <p>Enter a state number to query its name</p>";
42 </html><?php require_once __DIR__ . "/_append.php"; ?>