More tabs/to/spaces conversion, plus remove closing php tags as they are not consider...
[plcapi.git] / demo / client / client.php
1 <html>
2 <head><title>xmlrpc</title></head>
3 <body>
4 <h1>Getstatename demo</h1>
5 <h2>Send a U.S. state number to the server and get back the state name</h2>
6 <h3>The code demonstrates usage of the php_xmlrpc_encode function</h3>
7 <?php
8     include("xmlrpc.inc");
9
10     // Play nice to PHP 5 installations with REGISTER_LONG_ARRAYS off
11     if(!isset($HTTP_POST_VARS) && isset($_POST))
12     {
13         $HTTP_POST_VARS = $_POST;
14     }
15
16     if(isset($HTTP_POST_VARS["stateno"]) && $HTTP_POST_VARS["stateno"]!="")
17     {
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         {
28             $v=$r->value();
29             print "</pre><br/>State number " . $stateno . " is "
30                 . htmlspecialchars($v->scalarval()) . "<br/>";
31             // print "<HR>I got this value back<BR><PRE>" .
32             //  htmlentities($r->serialize()). "</PRE><HR>\n";
33         }
34         else
35         {
36             print "An error occurred: ";
37             print "Code: " . htmlspecialchars($r->faultCode())
38                 . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
39         }
40     }
41     else
42     {
43         $stateno = "";
44     }
45
46     print "<form action=\"client.php\" method=\"POST\">
47 <input name=\"stateno\" value=\"" . $stateno . "\"><input type=\"submit\" value=\"go\" name=\"submit\"></form>
48 <p>Enter a state number to query its name</p>";
49
50 ?>
51 <hr/>
52 <em>$Id$</em>
53 </body>
54 </html>