Thanks for clearing that for me.
I have as well a reset password system , but with a problem (as ever ..)
In this script with the reset password, when I enter my e-mail address and username I receive the new password , but it's not the same with the one in the database, meaning that the password changes in the database , but it's not the same , and for that I can't login with the password received.
Here's the script :
PHP Code:
<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$userid = $_SESSION['id'];
$username = $_SESSION['usr'];
?>
<?php
if (!$username && !$userid){
if ($_POST['resetbtn']){
// get the form data
$user = $_POST['user'];
$email = $_POST['email'];
// make sure info provided
if ($user){
if ($email){
if ( (strlen($email) > 4) && (strstr($email, "@")) && (strstr($email, ".")) ){
// connect
$connect = mysql_connect("localhost","x7euprr_regu","braine3211") or die("Wrong database connection");
mysql_select_db("x7euprr_reg") or die("Wrong database name");
$query = mysql_query("SELECT * FROM tz_members WHERE usr='$user'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
// get info about account
$row = mysql_fetch_assoc($query);
$dbemail = $row['email'];
// make sure the emial is correct
if ($email == $dbemail){
// generate password
$pass = rand();
$pass = md5($pass);
$pass = substr($pass, 0, 6);
$password = md5(md5("kjfiufj".$pass."Fj56fj"));
// update db with new pass
$querychange = mysql_query("UPDATE tz_members SET pass='$password' WHERE usr='$user'");
// make sure the paassword was changed
$query = mysql_query("SELECT * FROM tz_members WHERE usr='$user' AND pass='$password'");
$numrows = mysql_num_rows($query);
if ($numrows == 1){
// create email vars
$webmaster = "office@cs-uno.net";
$headers = "From: Games.CsuNo.nET<$webmaster>";
$subject = "Games.CsuNo.nET - Your New Password";
$message = "Hello! Your password has been reset. Your new password is below.\n";
$message .= "Password: $pass\n";
//echo $pass."<br />";
if ( mail($email, $subject, $message, $headers) ){
echo "Your password has been reset. An email has been sent with your new password.";
}
else
echo "An error has occured and your email was not sent containing your new password.";
}
else
echo "An error has occured and the password was not reset.";
}
else
echo "You enter the wrong email address.";
}
else
echo "The username was not found.";
mysql_close();
}
else
echo "Please enter a valid email address.";
}
else
echo "Please enter you email.";
}
else
echo "Please enter you username.";
}
echo "<form action='/lost_pw.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='user' /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' name='email' /></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='resetbtn' value='Reset Password' /></td>
</tr>
</table>
</form>";
}
else
echo "Please logout to view this page.";
?>
This is the database images :


Thanks again , dakata
Bookmarks