Android Code Snippet Register User example using HttpUtils2

Discussion in 'Code Snippets' started by aeric, Mar 27, 2015.

  1. G-ShadoW

    G-ShadoW Active Member Licensed User

    It's working now, I have switch to signup.php from first post.
    Also, register.php is missing?
     
  2. aeric

    aeric Active Member Licensed User

    (Register) signup.php returns:
    1. "Mail"
    2. "MailInUse"

    (Login) signin.php returns:
    1. "Not Found"
    2. "Not Activate"
    3. User Name

    Under Register module, it is unlikely to return "Not Found"

    register.php is not used in this example. I use signup.php for register.
     
    G-ShadoW likes this.
  3. G-ShadoW

    G-ShadoW Active Member Licensed User

    Yes, I have modified php, it's working now.
    But how to get Online user info :)
    It should be something in service module with timer, right ?
     
  4. aeric

    aeric Active Member Licensed User

    I am not sure how it is done correctly. My idea is the app will periodically create a job request to a php page to update a last_login field in the database then a php page will return a query based on the difference time between current time and the last_login time. Normally Discussion forum list the online user within 5 minutes.
     
  5. G-ShadoW

    G-ShadoW Active Member Licensed User

    Yes, from php it only count logins

    Code:
    $res = mysql_query("UPDATE tbl_member SET logins = logins + 1 WHERE user_id = '$uid'");
        print json_encode ($row[
    "user_name"]);
    online status remain N
     

    Attached Files:

  6. aeric

    aeric Active Member Licensed User

    Ya, I didn't implement the Online status. If you want to implement the Online status, I think it is not difficult to do it. As I mentioned, just update the value of last login in the table, in my table I have a time_stamp field which we can use for this purpose.
    PHP:
    $res mysql_query("UPDATE tbl_member SET logins = logins + 1, Online = 'Y', time_stamp = now() WHERE user_id = '$uid'");
    Then at some point before the above line or by using another php script (maybe we can use connect.php), we can run a query to update all user status to Online = 'N' when Current Time - Time Stamp > 60 seconds.
    PHP:
    $res mysql_query("UPDATE tbl_member SET Online = 'N' WHERE now()-time_stamp > 60");
     
    Last edited: Jul 7, 2015
  7. G-ShadoW

    G-ShadoW Active Member Licensed User

    I dont think that will work, there is no logout.
    If user exit app, it's stay's as online.
     
  8. aeric

    aeric Active Member Licensed User

    To force logout, just add in a btnLogout button which create a job to logout. The php web service will execute an SQL which look like below:
    PHP:
    $res mysql_query("UPDATE tbl_member SET Online = 'N' WHERE user_id = '$uid'");
    If a user exit the app without tapping on the btnLogout button, his status will updated to Online = 'N' when another user login after 60 seconds. You can set the value 60 to 1 seconds if you like.
     
  9. cruz109a

    cruz109a New Member Licensed User

    Hi
    Where I can found the register.php script?, thanks !
     
  10. aeric

    aeric Active Member Licensed User

    Hi, I use signup.php instead of register.php.
     
  11. mbayik

    mbayik Member Licensed User

    hi, thank you for the example, its very useful. im testing it but im taking connection problem..the app says "Connecting to server" and waiting then "error java.net sockettimeoutexpection

    my server address is

    Sub TestConnection
    Dim Connect As HttpJob
    Connect.Initialize("Connect", Me)
    Connect.Download("http://www.giritliyazilim.net/connect.php")
    ProgressDialogShow("Connecting to server...")
    End Sub
     
  12. aeric

    aeric Active Member Licensed User

    You can test to access the address using web browser.
     
  13. mbayik

    mbayik Member Licensed User

    hi again i tested web page it returns "connected"
     
  14. aeric

    aeric Active Member Licensed User

    You mean using web browser is okay but using the app, it shows timed out?
     
  15. mbayik

    mbayik Member Licensed User

    yes, i cant connect from the app
     
  16. mbayik

    mbayik Member Licensed User

    i changed my hosting to free hosting service, its connected. i will continue testing..
     
  17. cwkoomy

    cwkoomy Member Licensed User

    hi, i can register and active the user, but when login just show "an error has occured" , sorry newbie dont know which error is it
     
  18. aeric

    aeric Active Member Licensed User

    The free hosting server is facing DDOS attack. I suspect the scripts have been compromised or unable to run properly. Please upload the script to your server. Edit the domain name then test.
     
  19. cwkoomy

    cwkoomy Member Licensed User

    i use pay hosting, i change the signin.php update, then can login, but error " An error has occurred in sub:member_jobdone(java line:421) java.lang.NullPointerException
    and Welcome :null , is it change Login.strUserName to strUserID? :)?
     
  20. aeric

    aeric Active Member Licensed User

    After I changed the database password, the app can access the server now.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice