Re: Why isnt this value getting updated on the Server side?

Gaetano Giunta <[email protected]> Sun, 07 Sep 2008 12:33:08 +0200
Newsgroups gmane.text.xml.rpc.specification
Message-ID <[email protected]>
Sorry, but I fear you should study your php a little bit more...

The line
$FAILED_ATTEMPTS;
in the code does strictly nothing - as in php there is no need for 
variable declaration.
Otoh that variable is local to the function Login, ie. it will be 
created and destroyed every single time the function is executed.
No way it is going to be increased and shown back to the caller with the 
new value the next time the function is called.

Maybe you wanted to do this: global $FAILED_ATTEMPTS;
In this case the variable would be put in the global scope, and as such 
its value will persist across calls to the function Login and correctly 
be increased.

But you should also consider the stateless nature of a php web 
application: I am only speculating, but I suppose that the function 
Login is called many times via a new webservice call every time (and not 
many times inside the execution of the same php script). In such a 
situation, the variable, even if in the global scope, will be 
reinitialized with every webservice call, since the php script will be 
executed anew. To overcome this problem you should store the value in 
either the http session, in a cookie (but it might be tricky, some 
webservice clients do not support cookies) or in a database.


> Hi,
>
> Im using an java applet to communicate with an php server using xml-
> rpc. I created a login, but my variable $FAIL_ATTEMPTS is not adding
> and im getting worried that im way off.
>
> can anyone take a look?
>
> function Login($xmlrpcmsg)
> {
> $USERNAME = $xmlrpcmsg->getParam(0)->scalarVal();
> $PASSWORD = $xmlrpcmsg->getParam(1)->scalarVal();
>
> $FAILED_ATTEMPTS;
>
> $result = "Returned Data:" . "Username: " . $USERNAME . "
> Password: " . $PASSWORD;
>
> if($USERNAME == "Admin")
> {
> if($PASSWORD == "rooot")
> {
> return new xmlrpcresp(new xmlrpcval("Welcome
> administrator!","string"));
> }
>
> $FAILED_ATTEMPTS = $FAILED_ATTEMPTS + 1;
> return new xmlrpcresp(new xmlrpcval("Invalid
> Authorization! $FAILED_ATTEMPTS"));
>
> }
>
> return new xmlrpcresp(new xmlrpcval($result, "string"));
> }
>
> The client picks up the value of 1 if you enter in an invalid
> attempt, but if you do it more than once it doesnt show???
>
> Thank you very much,
>
> Aric
>
>  


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/xml-rpc/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/xml-rpc/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/