----- Original Message -----
From: Miguel Morales
To: [email protected]
Sent: Monday, June 06, 2011 5:46 PM
Subject: Re: [android-developers] login form
Wow, I really hope that's not for an enterprise application.
I believe this is a candidate for http://thedailywtf.com
Don't bother stripping bad characters/phrases, do this on the server side.
Also, don't ever mix UI code and networking code in the same thread.
Read:
http://developer.android.com/resources/articles/painless-threading.html
All I am trying to do is a simple simple log in form to a mobile version of
a site. You log in using the details from a mysql database and if it is ok
go to a welcome page and store the passwrod in shared preferences so that
next time it uses that to try and log in with. I am brand new to android
which must be obvious.
Can someone point me to an example
I have this as the onclick
btnLogin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String email =
StrippedChars(Email.getText().toString().trim());
String password =
StrippedChars(Password.getText().toString().trim());
String remember = StrippedChars(Remember.trim());
String url = StrippedChars(Url.getText().toString().trim());
final SharedPreferences mPreferences;
mPreferences = getSharedPreferences("CurrentUser", MODE_PRIVATE);
if(email.equals("guest") && password.equals("guest")){
SharedPreferences.Editor editor=mPreferences.edit();
editor.putString("Email", email);
editor.putString("PassWord", password);
editor.putString("Remember", remember);
editor.putString("Url", url);
editor.commit();
String urltemp = "http://www.extraplay.com/mobile/index.php";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(urltemp));
startActivity(i);
}
else {
SharedPreferences.Editor editor=mPreferences.edit();
editor.remove("Email");
editor.remove("PassWord");
editor.commit();
lblResult.setText("Login failed. Email address and/or password
doesn't exist.");
}
}
});
I need to change this
if(email.equals("guest") && password.equals("guest")){
SharedPreferences.Editor editor=mPreferences.edit();
editor.putString("Email", email);
editor.putString("PassWord", password);
editor.putString("Remember", remember);
editor.putString("Url", url);
editor.commit();
String urltemp = "http://www.extraplay.com/mobile/index.php";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(urltemp));
startActivity(i);
So that it post the details to the php script and either goes to the welcome
page and stores the login details in the preferences or come back with an
error message. The index page needs to test that the login session details
are set before it does anything. How do you do it? Do you post to the login
php script first ands test the return response then call
http://www.extraplay.com/mobile/index.php? Will the session variables which
were set in the php script still be set in index.php if you do that?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en