0

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."); 
    } 
} 
?>
7
Contributors
7
Replies
62
Views
5 Years
Discussion Span
Last Post by guruparthi
1

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.

0
<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>

Edited by Dani: Formatting fixed

-1

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

0

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>

Edited by Dani: Formatting fixed

0

.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.

-2
<?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';
  }
 }

?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.