PHP Code:
<title>Nepali AD Network | Forgot Password</title>
<?php
include "inc/header.php";
include "inc/def.php";
include "inc/usrchk.php";
if($guest==0) {
header("location:home.php");
}
?>
<?php
function rndgen ($minlength, $maxlength, $useupper, $usespecial, $usenumbers)
{
$charset = "abcdefghijklmnopqrstuvwxyz";
if ($useupper) $charset .= "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if ($usenumbers) $charset .= "0123456789";
if ($usespecial) $charset .= "~@#$%^*()_+-={}|]["; // Note: using all special characters this reads: "~!@#$%^&*()_+`-={}|\\]?[\":;'><,./";
if ($minlength > $maxlength) $length = mt_rand ($maxlength, $minlength);
else $length = mt_rand ($minlength, $maxlength);
for ($i=0; $i<$length; $i++) $key .= $charset[(mt_rand(0,(strlen($charset)-1)))];
return $key;
}
$hammad = rand(1,1000);
$code = secure('code');
$sec = secure('secode');
if(isset($_POST['mail'])) {
$mail = secure('mail');
$get = mysql_query("SELECT * FROM users WHERE mail='$mail'") or die('Oops Error....');
$get1 = mysql_fetch_array($get);
$usr = $get1['user'];
$mail = $get1['mail'];
$id = $get1['id'];
if($sec!=$code)
{
print "<div class='prob'>Wrong security code !</div>";
die();
}
if(mysql_num_rows($get)==0) {
die("NO such user !");
} else {
$key = rndgen(10,10,false,false,true);
$pass = md5($key);
}
$dox = mysql_query("UPDATE users SET pass='$pass' WHERE id='$id'");
$to = "$mail";
$subject = "Password Reset - NepalAD Network";
$message = "Hello $usr
You have Just Request New Password.
Your New passwod : $key
Regards
AdNepal Team";
$from = "noreply@nepalwap.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
if($dox) {
print "<div class='adbox'>New Password Have Been Send to Your Email. Now Login<a href='login.php'>here</a></div>";
}
?>
<div class="line">Forgot Password ?</div>
<form action="forgot.php" method="post">
<div class="lgn">E-Mail Address : <br />
<input size="30" maxlength="35" type="text" name="mail" /></div>
<?php
echo "<div class='lgn'>Security Code : '$hammad'<br />
<input size='30' maxlength='3' type='hidden' value ='$hammad' name='secode' />
<input size='30' maxlength='3' type='text' name='code' /></div>
<div class='lwt'>
<input type='submit' value='Get password' />
</div>";
?>
</form>
<a href="login.php"><b>Login here</b></a>
<?php include "inc/footer.php"; ?>
Comment