PLease help me how to send password to email

<form name="forgot" method="post" action="<?php $_SERVER['PHP_SELF'];?>"> 
<p><label for="email">Email:</label> 
<input name="email" type="text" value="" /> 
</p> 
<input type="submit" name="submit" value="submit"/> 
<input type="reset" name="reset" value="reset"/> 
</form> 
<?php 
if(isset($_POST['submit'])) 
{ 
$connect=mysql_connect("localhost","root","") or die("Could not connect to database");
mysql_select_db("dbsalon") or die(mysql_error()); 

$email = $_POST['email']; 
$sql= "SELECT  `password` FROM `register` WHERE `email` ='.$email.'"; 
$query = mysql_query($sql); 

if(!$query)  
    { 
    die(mysql_error()); 
    } 

if(mysql_affected_rows() != 0) 
    { 
$row=mysql_fetch_array($query); 
$password=$row["password"]; 
$email=$row["email"]; 
$subject="Verbazon.net - Password Request"; 
$header="From: webmaster@verbazon.net"; 
$content="Your password is ".$password; 
mail($email, $subject, $content, $header);  
print "An email containing the password has been sent to you"; 
    } 
else  
    { 
    echo("no such login in the system. please try again."); 
    } 
} 
?>

Recommended Answers

All 7 Replies

You're storing passwords in the clear? That's really not a good thing. :P

A better system is to store at least a non-reversible hash of the password. Then when the user forgets their password, give them a temporary link to a reset form.

<html><body>

<?php
session_start();

$email=$_POST['email'];

$connect=mysql_connect("localhost","root","") or die("Could not connect to database");

mysql_select_db("dbsalon", $connect) or die("Couldn't find db");


$email_check=mysql_query("SELECT password FROM users WHERE email='$email'");
$count=mysql_num_rows($email_check);
$subject="Login Info";
$message="Your password is .$count";
$from="From: cj_reonz@yahoo.com";

mail($email, $subject, $message, $from);
echo "your password has been email to you";

?>
</body>
</html>

Hey, can anybody explain to me how to get our password if we forgot? Can i have the complete codes for that?

I am able to generate password in database but the password should go to email.Password is not goin to email

This is my index page.

<html>
<head>
<title>Forget Password</title>
</head>
<body>
<h1>Forgot Password using php</h1>
<form name="frm" action="" method="post">
<table border="0">

<td>Username</td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="btn" value="Login" /></td>
</tr>
<tr>
<td align="right" colspan="2"><a href="retrievepass.php">Forgot password</a></td>
</tr>
</table>
</form>
</body>
</html>

.Password is not goin to email

In order to help you with these, you should publish your serverside scripts where you wrote the lines of code that send the email.

<?php
 if(isset($_POST['submit']))
 {
  $mail=$_POST['mail'];
  $q=mysql_query("select * password from register where mail='".$mail."' ") or die(mysql_error());
  $res=mysql_fetch_assoc($q);
  $password=$res['password'];
  $msg='Your password is '.$password;
  $sub='Send password';
  $header='From: your mail id';
  $m=mail($mail,$sub,$msg,$header);
  if($m)
  {
   echo'check your mail';
  }
 }

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.