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: fustigate@fustigate.net\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

Link to comment
Share on other sites

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'");
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.