Friday, 3 May 2013

Forgot Password Code for PHP + MySQL

Forgot Password PHP Language code.

If any user forgot their password then you can send them email or
To give them password on the same web page.
Here is the code which shows the password if user forgot it. Enter Username and Mobile no to show the password.


<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Forgot Password </title>
<?php
if(isset($_POST['submit']))
{
include('myconnection.php');
$un=trim($_POST['username']);
$mn=trim($_POST['mobileno']);

if(empty($un))
{
echo "<p style='color:red;'> Please Enter Your UserName </p>";
}
elseif(empty($mn))
{
echo "<p style='color:red;'> Please Enter Your Mobileno </p>";
}
else
{
$sql="select `password` from tbl_employer_reg where `emailid`='$un' and `mobile`='$mn'";
$result=mysqli_query($con,$sql);
$num_rows=mysqli_num_rows($result);
if($num_rows==1)
{
while($line=mysqli_fetch_array($result))
{
echo "your Password is ".$line['password'];
}
}
else
{
echo "Invalid Username/Mobileno";
}
}
}
?>
</head>

<body>

<h2 style="color:red"><center>  FORGOT PASSWORD </center></h2>
<form name="form"  method="post" action="">
<table border="0" >
<tr>
<td >Enter Your Username: </td>
<td> <input type="text" name="username" value=""  size="40" /></td>
</tr>
<tr>
<td >Enter your mobile no : </td>
<td> <input type="text" name="mobileno" value="" size="40" /></td>
</tr>
<tr>
<td> </td>
<td> <input type="submit" name="submit" value="SUBMIT"   /> </td>
</tr>
</table>

</form>
</div>
</body>
</html>

No comments:

Post a Comment