2 <head><title>xmlrpc</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 the php_xmlrpc_encode function</h3>
12 // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off
13 if (!isset($HTTP_POST_VARS) && isset($_POST)) {
14 $HTTP_POST_VARS = $_POST;
17 if (isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"] != "") {
18 $stateno = (integer)$HTTP_POST_VARS["stateno"];
19 $f = new xmlrpcmsg('examples.getStateName',
20 array(php_xmlrpc_encode($stateno))
22 print "<pre>Sending the following request:\n\n" . htmlentities($f->serialize()) . "\n\nDebug info of server data follows...\n\n";
23 $c = new xmlrpc_client("/server.php", "phpxmlrpc.sourceforge.net", 80);
26 if (!$r->faultCode()) {
28 print "</pre><br/>State number " . $stateno . " is "
29 . htmlspecialchars($v->scalarval()) . "<br/>";
30 // print "<HR>I got this value back<BR><PRE>" .
31 // htmlentities($r->serialize()). "</PRE><HR>\n";
33 print "An error occurred: ";
34 print "Code: " . htmlspecialchars($r->faultCode())
35 . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
41 print "<form action=\"client.php\" method=\"POST\">
42 <input name=\"stateno\" value=\"" . $stateno . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>
43 <p>Enter a state number to query its name</p>";