Fix newlines (to satisfy automated code quality scanners)
[plcapi.git] / demo / client / client.php
1 <html>
2 <head><title>xmlrpc</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 the php_xmlrpc_encode function</h3>
9 <?php
10 include "xmlrpc.inc";
11
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;
15 }
16
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))
21     );
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);
24     $c->setDebug(1);
25     $r = &$c->send($f);
26     if (!$r->faultCode()) {
27         $v = $r->value();
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";
32     } else {
33         print "An error occurred: ";
34         print "Code: " . htmlspecialchars($r->faultCode())
35             . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
36     }
37 } else {
38     $stateno = "";
39 }
40
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>";
44
45 ?>
46 </body>
47 </html>