![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 7 of 7 total |
![]() |
Sat, Nov 5 2016 3:45 AM | Permanent Link |
StewCam | My project has a basic login form to elicit username and password. The credentials are sent as URL query parameters and are compared with values stored in a MySQL database (stored password is hashed). The PHP script then returns JSON to the app. A valid login returns:
{"rows": [{"user":"OK","pass":"OK"}]} The user is then taken to the main form. This all works fine except for the fact that the login always fails at the first attempt. It then works until the browser is refreshed or restarted. The PHP script is not faulty, as it always returns the correct response when queried directly from the browser. The script is called from the app with the following code: Database.BaseUrl := 'php/admit.php?user=' + EditUsr.Text + '&pass=' + EditPass.Text; Database.LoadRows(DS); I presume this is a session-based error but if so, how do I address this in the app? The PHP script commences with session_start() and always returns the correct response anyway. I tried adding a timer to the app and running the script a second time at login but that doesn't work. Any suggestion would be valued. |
Sat, Nov 5 2016 7:50 AM | Permanent Link |
Matthew Jones | Watch the network traffic in the Chrome debugger.
-- Matthew Jones |
Sat, Nov 5 2016 9:56 AM | Permanent Link |
StewCam | >>Matthew Jones wrote:
>> >>Watch the network traffic in the Chrome debugger. Thanks, I followed your suggestion but there I couldn't find any significant difference between the first and subsequent logins. |
Sat, Nov 5 2016 11:16 AM | Permanent Link |
Raul ![]() | On 11/5/2016 9:56 AM, StewCam wrote:
>>> Matthew Jones wrote: >>> Watch the network traffic in the Chrome debugger. > Thanks, I followed your suggestion but there I couldn't find any significant difference between the first and subsequent logins. I would suggest show or describe your client side logic then - if server response is same then there is an issue with your EWB login handling code. Raul |
Sat, Nov 5 2016 10:31 PM | Permanent Link |
StewCam | >>Raul wrote:
>> >>I would suggest show or describe your client side logic then - if server >>response is same then there is an issue with your EWB login handling code. The login handling code is as follows: URL := 'php/admit.php?user=' + EditUsr.Text + '&pass=' + EditPass.Text'; Database.BaseUrl := URL; Database.LoadRows(DS); if (DS.Columns['user'].AsString = 'OK') and (DS.Columns['pass'].AsString = 'OK') then begin FormMain := TFormMain.Create(Nil); FormMain.ShowModal; FormLogin.Hide; end else begin MessageDlg('Error in internet connection or login details', 'Login error',mtError,[mbRetry],mbRetry,MsgDlgResult,True); EditPass.SetFocus; end; For some reason the first login attempt seems to generate null values for 'user' and 'pass', even though the PHP scrip always gives the correct response when queried directly from the browser. |
Sun, Nov 6 2016 2:15 AM | Permanent Link |
Uli Becker | > Database.LoadRows(DS);
> if (DS.Columns['user'].AsString = 'OK') and (DS.Columns['pass'].AsString = 'OK') then > ... Due to the asynchronous nature of javascript you have to wait until the dataset has been loaded before you can access any values. The solution is to put the code after Database.LoadRows(DS) in the "AfterLoad" event handler of the dataset. By doing so you make sure that the dataset has been loaded before accessing any values. Uli |
Sun, Nov 6 2016 3:50 AM | Permanent Link |
StewCam | >>Uli Becker wrote:
>> >>Due to the asynchronous nature of javascript you have to wait until the >>dataset has been loaded before you can access any values. >> >>The solution is to put the code after Database.LoadRows(DS) in the >>"AfterLoad" event handler of the dataset. By doing so you make sure that >>the dataset has been loaded before accessing any values. Many thanks, Uli - your advice makes perfect sense and works too! |
This web page was last updated on Friday, December 1, 2023 at 06:01 PM | Privacy Policy![]() © 2023 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |