Jump to content

Password reset help


NLT

Recommended Posts

I tried to make it so it counts the pass_reset table and if there is no confirm_code for the confirmation code it displays a certain error. I need it to display something else if it's valid also. I tried this:

<?
include('config.php');
$confirmation=$_GET['code'];



$table1="pass_reset";


$selectkey="SELECT * FROM $table1 WHERE confirm_code ='$confirmation'";
$gotkey=mysql_query($selectkey);


if($gotkey){
$count=mysql_num_rows($gotkey);
}
if($count==1){
$rows=mysql_fetch_array($gotkey);
$email=$rows['email'];
}


$table2="users";

$query_user="SELECT username FROM $table2 WHERE mail='$email'";
        $query=mysql_query($query_user);
        $row = mysql_fetch_array($query);
        $user = $row['username']; 

$plain_password = substr ( md5(uniqid(rand(),1)), 3, 10);
$md_password   = md5($plain_password);

mysql_query("UPDATE users SET password='{$md_password}' WHERE mail='{$email}' LIMIT 1");


$to=$email;

	$subject="Your new password - $hotel_name";

	$header="From: [email protected]\r\n";
	$message="Your new passwordr\n";
	$message.="You can now log in with this password: $plain_password\r\n";
	$message.="Be sure to change it as soon as you log in!";

	$sentmail = mail($to,$subject,$message,$header);


$validateq1 = mysql_query("SELECT * FROM pass_reset WHERE confirmation='$confirmation'");	
$validation1 = mysql_num_rows($validateq1);
{
if($validation1==0);
echo "Your confirmation code is not valid.";
}
mysql_query("DELETE from `pass_reset` WHERE `confirm_code`='$confirmation'");





?>

 

Errors though

This:

 

{
if($validation1==0);
echo "Your confirmation code is not valid.";
}
mysql_query("DELETE from `pass_reset` WHERE `confirm_code`='$confirmation'");

 

Should be:

 

if($validation1==0)
{
echo "Your confirmation code is not valid.";
} else {
mysql_query("DELETE from `pass_reset` WHERE `confirm_code`='$confirmation'");
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.