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 8901243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:18:00+00:00 2026-06-15T01:18:00+00:00

I have the following code to retrieve the password of a user from the

  • 0

I have the following code to retrieve the password of a user from the database and email to him. I am successfully able to send a user his password if his email is present in the database. But in the event that the email doesn’t exist, I want the code to echo that the email for the particular user doesn’t exist in the database. My code gives me the below result if an invalid email is entered in the form:

Failed to add recipient: @localhost [SMTP: Invalid response code received from server (code: 555, response: 5.5.2 Syntax error. v9sm2318990paz.6)]

I have tried using the if-else statement for this purpose. Here’s the code I wrote:

<?php

//Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect to server");
mysql_select_db("$db_name")or die("cannot select DB");

// email value sent from HTML form
$email_to=$_POST['email'];

// table name
$tbl_name="registration";

if($mysql1 = "SELECT ID,Email,Password FROM $tbl_name WHERE Email='$email_to' ORDER BY ID DESC ")
{
$selectemail = mysql_query($mysql1);

$shah       =   mysql_fetch_array($selectemail);
$EMAIL      =   $shah['Email'];
$UID        =   $shah['ID'];
$password           =       $shah['Password'];

require_once "/home/computat/php/Mail.php";

$from = "abhishekagrawal.988@gmail.com";
$to = $EMAIL;  

$subject = "Your password for www.computationalphotography.in";
$body    = "Your password for logging on to our website www.computationalphotography.in is:\n$password\r\nIf you have any additional queries, kindly write to us at abhishekagrawal.988@gmail.com\r\n\nThanks & Regards\nThe Computational Photography Team\n";   

    $host = "ssl://smtp.gmail.com";
    $port = "465";
    $username = "abhishekagrawal.988@gmail.com";  //
    $password = "*********";

    $headers = array ('From' => $from,
      'To' => $to,
      'Subject' => $subject);
    $smtp = Mail::factory('smtp',
      array ('host' => $host,
        'port' => $port,
        'auth' => true,
        'username' => $username,
        'password' => $password));

    $mail = $smtp->send($to, $headers, $body);

    if (PEAR::isError($mail)) {
      echo("<p>" . $mail->getMessage() . "</p>");
     } else {
      echo("<p></p>");
     }
}
else{
echo "<b><center>Email not found in the database</center></b>";
}
/*    
  • 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-15T01:18:01+00:00Added an answer on June 15, 2026 at 1:18 am

    Use this

    $mysql1 = mysql_query("SELECT ID,Email,Password FROM $tbl_name WHERE Email='$email_to' ORDER BY ID DESC ");
    if(mysql_num_rows($mysql1)){
          //exists in db
    }
    else{//does not exist}
    

    Avoid using mysql_*functions use mysqli_* or PDO as mysql_* is being depreciated

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

Sidebar

Related Questions

I have the following line code used to retrieve data from database: DataTable newEquipmentTable
I have the following code to retrieve a dataset from a database. I would
I have the following code, which will retrieve a filename from a table and
I have the following code through which i am able to retrieve phone numbers.
How do I retrieve an int from NSUserDefaults? I have the following code NSUserDefaults
Hello and good day to all. I have the following code to retrieve from
Powershell unrolling is driving me crazy. I have the following code to retrieve email
Hello I have the following code to retrieve data from my db using nhibernate
I have written php code to retrieve data from database to div in webpage.i
I have following code in HTML, and I would like to retrieve name12@host.com from

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.