Y no se que error cometí ni como solucionarlo:
resetpassword.php?code=7825192668 y en la base de datos era otro.
el codigo es este:
Código PHP:
<?
$url_code = check_input($_REQUEST['code']);
$result = mysql_query("SELECT * from users where code='$url_code'");
if(mysql_num_rows($result) ==0) {
echo "Wrong reset code!";
@mysql_close();
}
else {
while ($row = mysql_fetch_assoc($result)) {
$pass=$row['password'];
$uname=$row['username'];
$code=$row['code'];
$email=$row['email'];
}
$newpassword = rand(1111111111,9999999999);
$md5_newpassword=md5($newpassword);
$sql1="UPDATE users SET password='$md5_newpassword' where code='$url_code'";
mysql_query($sql1);
$sql2="UPDATE users SET code='0' where code='$url_code'";
mysql_query($sql2);
@mysql_close();
///Mail User
$subject = "New password";
$to = $email;
$from = $support_email;
$body= "Hello $uname, <br /><br />
This is your updated account details. <br /> User name: $youname <br /> Password: $newpassword<br /><br /> To log into your account with those details click the link below <br /> $server_url/login.php <br /><br />Please remember to change this password when you log in with something you can easily remember.<br /><br />------------------------------------------------<br /> This is an automated E-mail from <br /> $site_name ";
$headers = "From: " . $from . "\n";
$headers .= "X-Sender: <" . "$to" . ">\n";
$headers .= "Return-Path: <" . "$to" . ">\n";
$headers .= "Error-To: <" . "$to" . ">\n";
$headers .= "Content-Type: text/html\n";
mail($to,$subject,$body,$headers);
echo "New password has been sent to your email, redirecting to login page shortly";
?>
<META HTTP-EQUIV="Refresh"
CONTENT="5; URL=login.php">
<?
}
?>
Código PHP:
<div id="error" style="display:none;"><div class="msg" id="sucmsgid"></div><div class="error" id="msgid"></div></div>
<form name="config" action="<?= $_SERVER['PHP_SELF'] ?>" method="post" style="margin-top: 0px; margin-bottom: 0px;" onSubmit="return forgetpass();">
<div class="profile">
<div class="row">
<div class="rowleft">
<span class="fontcolor"><b>Email :</b></span>
</div>
<div class="rowright">
<input type="text" name="email" id="email" value="<?=$youname?>" size="40" maxlength="255" />
</div>
</div>
<br /><br />
<div class="row">
<div class="rowleft">
</div>
<div class="rowright">
<input name="submit" value="Restablecer contraseña" type="submit" >
</div>