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

This forum contains topics that were moved from Get Satisfaction
Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

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

Post 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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Post by Kateryna Grynko »

Hi Stg,

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

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

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

Post 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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Post 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/...

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

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

Post 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

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

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

Post by Evgene Karachevtsev »

Hello Stelios,

Could you please give an example of response service?

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

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

Post 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.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

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

Post 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.

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

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

Post 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..

Stelios Geo
Posts: 0
Joined: Wed May 14, 2014 11:37 am

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

Post 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

Post Reply