Ayabonga
Member
Hello Guys,
I have two activity modules named "Login" and "Main". In the login activity i have a diffrent layout for it where a user types username and password to login. After succesful login it then goes to "Main" activity and it also has a diffrent layout. In the Main module thats where most of the code run but now i want to save the info from the textboxes were the user types information save it into Php MyAdmin database according to the user logged in. Currently I can save the information but not according to the users who wrote the information, The User ID is aways 1.
My sql command to save is : sql.save = INSERT history (Remy, Henny, Soda) VALUES (?, ?, ?)
But now i cannot save these values according to the user because I cannot access Username and Password in the Main module to make it like: sql.save = INSERT history (Remy, Henny, Soda) VALUES (?, ?, ?) WHERE Username = ? AND Password = ?
I tried Using CallSubDelayed but i dont understand properly how to implement it and process globals.
Please check the attached code.
I have two activity modules named "Login" and "Main". In the login activity i have a diffrent layout for it where a user types username and password to login. After succesful login it then goes to "Main" activity and it also has a diffrent layout. In the Main module thats where most of the code run but now i want to save the info from the textboxes were the user types information save it into Php MyAdmin database according to the user logged in. Currently I can save the information but not according to the users who wrote the information, The User ID is aways 1.
My sql command to save is : sql.save = INSERT history (Remy, Henny, Soda) VALUES (?, ?, ?)
But now i cannot save these values according to the user because I cannot access Username and Password in the Main module to make it like: sql.save = INSERT history (Remy, Henny, Soda) VALUES (?, ?, ?) WHERE Username = ? AND Password = ?
I tried Using CallSubDelayed but i dont understand properly how to implement it and process globals.
Please check the attached code.
Login Activity Code:
Sub btnSignIn_Click
If editUsername.Text = "" Or editPassword.Text = "" Then
ToastMessageShow("username or password data is missing!",True)
Log("username or password data is missing")
Return
End If
Dim req As DBRequestManager = CreateRequest
Dim cmd As DBCommand = CreateCommand("check_user", Array As String(editUsername.Text, editPassword.Text))
Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
If j.Success Then ' Call to jRDC2 server was successful
req.HandleJobAsync(j,"req")
Wait For (req) req_Result(res As DBResult)
If res.Rows.Size > 0 Then ' One or more records have been returned
StartActivity(Main)
ToastMessageShow("Login Successful",True)
Log("User successful Login!")
Else ' No records were returned
ToastMessageShow("Please Register as new user",True)
Log("Please Register as new user")
End If
Else ' Something went wrong with the call to the jRDC2 server
Log("Something went wrong!!!!!!")
Log("Error: " & j.ErrorMessage)
End If
j.Release
End Sub
Main Activity Code:
Sub btn_Execute_Click
If connected Then
Save
End If
End Sub
Sub Save As ResumableSub
Dim cmd As DBCommand = CreateCommand("save", Array As String(Remytxt.Text, Hennytxt.Text, Sodatxt.Text))
Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
Wait For(j) JobDone(j As HttpJob)
If j.Success Then
Log("Inserted successfully!")
ToastMessageShow("Drink saved",True)
Else
Log("Error: " & j.ErrorMessage)
End If
j.Release
Return j.Success
End Sub
Last edited: