Page 1 of 2

Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 9:17 am
by Stelios Geo

Hello,
I'm currently practicing on making a business application reading data from xml restservice which is working fine. i can show data from my sql server on the screen.
What i want is to make a login screen on the application, just a simple user name and password and a button. User name and password are stored in my sql database. I do not know how this could work:

  1. i could use my php file that exports the xml while it joins with the users table, and when the response text is empty then authentication is failed - otherwise move to next screen.

  2. or i could just read the user name and password from the table and compare them with the user input.

    Also, Im not a js wizard, so if you could help me with that in detail, i would be greatful

    Thank you in advance,

    Stg


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 11:42 am
by Kateryna Grynko

Hi Stg,

It's better to send login and password to your server and check them on server side.


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 12:16 pm
by Stelios Geo

Hi Kateryna, thank you for your reply.
You mean to implement a server code script in Appery? or on my php script?
How can I do the first case? server code?
or on second case (php script) which is closer to my case, how can do the authentication?
I have a button, i.e. "Login" below a user&pass input textboxes. The login button calls the service to retreive my xml data. I was thinking that if the php returns empty then the authentication fails, which is fine by me. So how do i read the php content from javascript, or how i check when the xmlRequest is empty from the Login button?

Thank you,
Stg


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 12:33 pm
by Kateryna Grynko

Hi Stg,

It's better to implement this on server side, on your PHP script.

Not sure what data is supposed to be returned from your server, but you would probably need some custom logic like here:
https://getsatisfaction.com/apperyio/...


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 1:45 pm
by Stelios Geo

Hi,

Thanks for the link, i had followed that method, but my php file returns always success :) either the responseText is empty or full with data.

if(data.length == 0){
alert("error");
//Here you write code for "error" event handler.
}
i guess i can see when the "data.length" is null or not but what is the js code for my restService request? :)
Lets say i have a service of a php file that retures xml and tis called:
myRestService
how can i add myRestService.responseText = null or whatever on the button?? :)

Thank you very much


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 5:11 pm
by Evgene Karachevtsev

Hello Stelios,

Could you please give an example of response service?


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Thu Oct 16, 2014 8:41 pm
by Stelios Geo

Hello,
well assuming i push the login button, i call a url (php script file) that returns a Xml text, so the response service is just xml, but before that i would like to call a js script that would define if this xml is empty or no :)

Lets say i have this screen
Image

and on my button i have this service calling
Image

This is my service and on my php file (server side) i got two parameters (usr name & pass)
Image

and on my php file i join the user name & pass so i f the credentials are right the response will return the xml file, otherwise it will return empty.


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Fri Oct 17, 2014 8:49 pm
by Evgene Karachevtsev

Hello Stelios,

[quote:]before that i would like to call a js script that would define if this xml is empty or no" [/quote]
Sorry, I'm not sure I understand you correctly, could you please clarify this in details? You may find out is xml an empty or not, only after the service executes, i.e. on success or complete event service.


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Mon Oct 20, 2014 6:23 am
by Stelios Geo

Yes, im sorry for bad explanation. thats what I want. I found a workaround by passing the xml content to an invisible memo at the Login screen and got my if...else statements when this memo is empty or not..


Mobile app Rest Service from sql server through php - Authentication Login screen

Posted: Mon Oct 20, 2014 11:50 am
by Stelios Geo

Actually, there is one big problem. Where can i create a local storage variable????
In previous builder i was just typing in the mapping screen and then create the variable. I dont see any option like this in the new builder, how do i create storage variables?

Thank you,

Stg