• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Forget Password is send to registered email in android

krishnaveni

Well-Known Member
I have developed a login form (username,password and submit button) using a MySQL connection through soap webservices in my android application. Here I forget my password means I can't access my account, then how is access my account. So when I forget my password means click the forget password textview,then it is go to forget password activity. Here when I enter my email id means my password is retrieve from mysql database and send it to my email id.

How can I do, please guide me. This is my webservice code:
Code:
public class XcartLogin {
 public String authentication(String userName,String password){
   
  String retrievedUserName = "";
  String retrievedPassword = "";
  String status = "";
  try{
    
   Class.forName("com.mysql.jdbc.Driver");
   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro","root","");
   PreparedStatement statement =  con.prepareStatement("SELECT * FROM customers WHERE login = '"+userName+"'");
   ResultSet result = statement.executeQuery();
    
   while(result.next()){
    retrievedUserName = result.getString("login");
    retrievedPassword = result.getString("password");
    }
    
   if(retrievedUserName.equals(userName)&&retrievedPassword.equals(password)){
    status = "Success!";
    
   }
    
   else{
    status = "Login fail!!!";
   }
    
  }
  catch(Exception e){
   e.printStackTrace();
  }
  return status;
  
 }
 
}

This is my forgetpassword webservice code is:
Code:
public class ForgetPassword {
 public String authentication(String Email){
   
  
  String retrievedEmail = "";
  String status = "";
  try{
    
   Class.forName("com.mysql.jdbc.Driver");
   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pro","root","");
   PreparedStatement statement =  con.prepareStatement("SELECT password FROM customers WHERE email = '"+Email+"'");
   ResultSet result = statement.executeQuery();
    
   while(result.next()){
   
    retrievedEmail = retrievedEmail + result.getString("password");
    retrievedEmail = result.getString("email");
    }
    
   if(retrievedEmail.equals(Email)){
    status = "Your password has been sent to your email address";
    }
    
   else{
    status = "No such user exist";
   }
    
  }
  catch(Exception e){
   e.printStackTrace();
  }
 
  return retrievedEmail;
 }
 
}

dis is my android code for forget password:
Code:
public class ForgetPassword extends Activity {
 private final String NAMESPACE = "http://ws.userlogin.com";
    private final String URL = "http://192.168.1.168:8085/Login/services/ForgetPassword?wsdl";
    private final String SOAP_ACTION = "http://ws.userlogin.com/authentication";
    private final String METHOD_NAME = "authentication";
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.forget_password);
        Button submit = (Button) findViewById(R.id.submit);
        submit.setOnClickListener(new View.OnClickListener() {
    
   public void onClick(View arg0) {
    loginAction();
     
   }
  });
    }
     
    private void loginAction(){
     SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
     boolean isUserValidated = true;
        EditText Email = (EditText) findViewById(R.id.email);
        String email = Email.getText().toString();
    
      //Pass value for userName variable of the web service
        PropertyInfo unameProp =new PropertyInfo();
        unameProp.setName("Email");//Define the variable name in the web service method
        unameProp.setValue(email);//set value for userName variable
        unameProp.setType(String.class);//Define the type of the variable
        request.addProperty(unameProp);//Pass properties to the variable
        
     
           
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
         
        try{
            androidHttpTransport.call(SOAP_ACTION, envelope);
               SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
               String status = response.toString();
               TextView result = (TextView) findViewById(R.id.tv_status);
               result.setText(response.toString());
               if(status.equals("Success!"))
               {
                   
                   //   ADD  to save  and  read next time
                       String strUserName = Email.getText().toString().trim();
                      
                       if (null == strUserName || strUserName.length() == 0)
                                   {
                           //  showToast("Enter Your Name");
                         Email.setError( "Email is required!" );
isUserValidated = false;
                       }
        }
               if(isUserValidated)
               {
                   

                              Intent intent = new Intent(ForgetPassword.this,AndroidLoginExampleActivity.class);
                              
                                
                                startActivity(intent);
                            
               }
              

                                                  
                              
                                      else
                                         {
                                          Intent i = new Intent(getApplicationContext(), ForgetPassword.class);
                                            startActivity(i);
                                         }
                                        }


        catch(Exception e){
           
        }
       }
     
}
Please help me,how to do this?
 
Back
Top Bottom