Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8450373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:57:07+00:00 2026-06-10T10:57:07+00:00

Have been trying on these codes and I want to send a email which

  • 0

Have been trying on these codes and I want to send a email which will auto generate the password and the random password will then update in my database column which is the encrypted_password.

I really dont know whats wrong with my code. I am new to this android application and also using the php. And i did see some other questions that are link to mine, however, I still cant solve it. Can anyone please help me? I really need help on this for my final year project.

Another thing is also after sending the email with the random generated password, the random generated password cannot be updated into my database column.

This is my error:

08-29 10:44:10.976: E/JSON Parser(1594): Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
08-29 10:44:10.987: W/dalvikvm(1594): threadid=10: thread exiting with uncaught exception (group=0x40014760)
08-29 10:44:11.006: E/AndroidRuntime(1594): FATAL EXCEPTION: AsyncTask #1
08-29 10:44:11.006: E/AndroidRuntime(1594): java.lang.RuntimeException: An error occured while executing doInBackground()
08-29 10:44:11.006: E/AndroidRuntime(1594):     at android.os.AsyncTask$3.done(AsyncTask.java:266)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:574)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.lang.Thread.run(Thread.java:1020)
08-29 10:44:11.006: E/AndroidRuntime(1594): Caused by: java.lang.NullPointerException
08-29 10:44:11.006: E/AndroidRuntime(1594):     at com.pivestigator.login.ForgetPasswordActivity$SendEmail.doInBackground(ForgetPasswordActivity.java:93)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at com.pivestigator.login.ForgetPasswordActivity$SendEmail.doInBackground(ForgetPasswordActivity.java:1)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at android.os.AsyncTask$2.call(AsyncTask.java:252)
08-29 10:44:11.006: E/AndroidRuntime(1594):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)

my android code:

 public class ForgetPasswordActivity extends Activity {

EditText textforgetEmail;
TextView email_error;

 // Progress Dialog
private ProgressDialog pDialog;

 private static String url_email = "...";

// JSON Node names
        private static final String TAG_SUCCESS = "success";

    JSONParser jsonParser = new JSONParser();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.forget_password);

    Button buttonSubmit = (Button) findViewById(R.id.buttonSubmit);
    textforgetEmail = (EditText) findViewById(R.id.forgetEmail);
    email_error = (TextView) findViewById(R.id.email_error);

    // Link to Login Screen
    buttonSubmit.setOnClickListener(new View.OnClickListener() {

            public void onClick(View view) {
                // creating new product in background thread
                new SendEmail().execute();
            }
    });

}

class SendEmail extends AsyncTask<String, String, String> {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(ForgetPasswordActivity.this);
       // pDialog.setMessage("Sending Email..");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
       // pDialog.show();
    }

    protected String doInBackground(String... args) {
        runOnUiThread(new Runnable() {
            public void run() {
                // SENDING EMAIL METHOD HERE
                String sendemail = textforgetEmail.getText().toString();

                // Building Parameters
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                params.add(new BasicNameValuePair("email", sendemail));

                // getting JSON Object
                // Note that forgotPassword URL accepts POST method
                JSONObject json = jsonParser.makeHttpRequest(
                        url_email, "POST", params);

                // check log cat for response
                 //Log.d("Sending email Response", json.toString());

                // check for success tag
                try {
                    int success = json.getInt(TAG_SUCCESS);

                    if (success == 1) {
                        // successfully email sent
                        Intent intent = new Intent(getApplicationContext(),
                                ForgetPasswordConfirmActivity.class);
                        startActivity(intent);
                        finish();
                    } else {
                        // failed to send email
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
        return null;
    }

    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        pDialog.dismiss();
    }
}

 }

and my php file:

<?php

$response = array();

$random = str_rand();

 function str_rand($length = 8, $seeds = 'alphanum')
{
// Possible seeds
$seedings['alpha'] = 'abcdefghijklmnopqrstuvwqyz';
$seedings['numeric'] = '0123456789';
$seedings['alphanum'] = 'abcdefghijklmnopqrstuvwqyz0123456789';
$seedings['hexidec'] = '0123456789abcdef';

// Choose seed
if (isset($seedings[$seeds]))
{
    $seeds = $seedings[$seeds];
}

// Seed generator
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
mt_srand($seed);

// Generate
$str = '';
$seeds_count = strlen($seeds);

for ($i = 0; $length > $i; $i++)
{
    $str .= $seeds{mt_rand(0, $seeds_count - 1)};
}

return $str;
}

// check for required fields
if (isset($_POST['email'])) {

$email = $_POST['email'];


$to = $email;
$subject = 'This is an email.';
$body = 'Hi,'."\n\n".'This is your new password: '."$random".'test';
$headers = 'From: noreply@pivestigator.netne.net';

if (mail($to, $subject, $body, $headers)) {
// include db connect class
require_once __DIR__ . '/DB_Connect.php';

// connecting to db
$db = new DB_CONNECT();

// check if row inserted or not
if ($result) {
    // successfully inserted into database
    $response["success"] = 1;
    $response["message"] = "Email successfully sent.";

    // echoing JSON response
    echo json_encode($response);
} 

}
else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";

// echoing JSON response
echo json_encode($response);
}
 }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:57:09+00:00Added an answer on June 10, 2026 at 10:57 am

    As the error message says:

    [..snip..] json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
                                         ^^^
    

    The JSON string you’re trying to parse is invalid – looks like it’s got some raw HTML, which mean it’s either badly generated, or PHP is inserting errors/warnings and destroying the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to compute the total sum of all these ord s
I have been trying to generate report as per age differences of different months
I have been trying to create a ListView which I can sort using drag
I keep on having these same two problems. I have been trying to use
I have been trying to delete images from a remote server. I don't want
I have been trying to plot these on a scatter chart using google api.
Is there anyone who knows this? I have been trying this for the last
Have been trying to encrypt an xml file to a string so that I
Have have been trying to make a validator for my xml files. I have
I have been trying to setup git for our web development team unsuccessfully. Some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.