hello,
I want to create a forgot password in my login page.
This is my codings but i am getting error.
The erroe is. "no such login in the system. please try again..
forgot_password.php
<?php
if(isset($_POST['submit']))
{
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("recruiter") or die(mysql_error());
$id = $_POST['id'];
}
$sql="SELECT * FROM login WHERE id='.$id.'";
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0)
{
print "no such login in the system. please try again.";
exit();
}
else {
$row=mysql_fetch_array($r);
$password=$row<"password">;
$email=$row<"email">;
$subject="your password";
$header="from:you@yourdomain.com";
$content="your password is ".$password;
mail($email, $subject, $row, $header);
print "An email containing the password has been sent to you";
}
?>
for.php
<html>
<head>
</head>
<body>
<form name="forgot" method="post" action="forgot_password.php">
Enter ur id:
<input name="id" type="text" value="" />
<input type="submit" name="submit" value="submit"/>
<input type="reset" name="reset" value="reset"/>
</form>
</body>
</html>
If anyone knows let me know the solution.