Jump to content

Why Reset Password wont work?


princeofpersia

Recommended Posts

Hi

 

I have the code below when users firget their password, they fill forrgot password form and an email will be sent to them which directs them to a page where (code below) they can reset their password.

 

When i fill the form I get the msg it says password has been changed however it wont change it in database. I have checked the code, current entries in database etc but still it wont change the password. Can u please what im doing wrong?

 

<?php 

include 'global.php';
$account_reference = $_GET['code'];
echo "$account_reference";
    
    
if (isset($_POST['resetpassword']) && $_POST['resetpassword'])
    {

$email = addslashes(strip_tags($_POST['email']));
$username = addslashes(strip_tags($_POST['username']));
$password = addslashes(strip_tags($_POST['password']));
$newpasswordnomd = addslashes(strip_tags($_POST['newpassword']));
$repasswordnomd = addslashes(strip_tags($_POST['repassword']));
$code = addslashes(strip_tags($_POST['code']));


$getdata=mysql_query("SELECT * FROM users WHERE username='$username' AND email='$email' AND code='$code'");
while($row = mysql_fetch_array($getdata))
{
$got_username=$row['username'];
$got_email=$row['email'];
$got_ref=$row['code'];
$got_pass=$row['password'];
}

$newpassword = md5($newpasswordnomd);
$repassword = md5($repasswordnomd);

if($password==$got_pass)

{
if ($email==$got_email)
{
	if ($username==$got_username)
	{
		if($newpassword==$repassword)

	{ $resetpass=mysql_query("UPDATE users SET password='$repassword' WHERE email=='$email' AND username=='$username'");

	echo "Your Password has been reset";
	}

		else {echo "Your New Password and Repeat Password do not match";}
		}
	else {echo "Your Username does not match our records";}
	}
else {echo "Your Email does not match our records";}
}


}


    ?>

    <form action='' method='POST' enctype='multipart/form-data'>	

<input type="hidden" name='code' value="<?php echo "$account_reference";?>"><p />

Email: <br/>

<input type="email" name='email'><p />

Username: <br/>
<input type='text' name='username'><p />

Password: <br/>
<input type='text' name='password'><p />

New Password: <br/>
<input type='text' name='newpassword'><p />

Repeat New Password: <br/>
<input type='text' name='repassword'><p />

<input type='submit' name='resetpassword' value='Update'>

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.