Jump to content

Why Reset Password wont work- Can u help please?


princeofpersia

Recommended Posts

Hi guys

 

I have this code, where it gets clicked from an email and then compares the tmp password etc and updates the new password in md5 format. I have been trying to find the issue why it doesnt update the password but i couldn't

 

can u help me to find out why? Please note all the db field names are correct in the code below. thanks in advance

 

 

<?php
include ("include/global.php");
include ("include/function.php");

$code = $_GET['code'];

    if (!$code){
Header("Location: forgotpassword.php");
}
else
{
if (isset($_POST['reset']) && $_POST['reset'])
{

$myemail=$row['email'];	 
$mycurrentpass=$row['currentpass'];
$mynewpass=$row['newpassword'];
$myrepass=$row['repassword'];	 
//


$getcurrentinfo=mysql_query("SELECT email,password FROM users WHERE email='$myemail'");
while($row = mysql_fetch_array($getcurrentinfo))
{
$currentemail=$row['email'];
$currentpass=$row['password'];
}	 
//	

  $newpassword = md5($mynewpass);
  $repeatpassword = md5($myrepass);


if($myemail==$currentemail&& $currentpass==$mycurrentpass)


 {

if($newpassword==$repeatpassword)

{

	$updatepass=mysql_query("UPDATE users SET password='$newpassword' WHERE email='$myemail'");

	}	 
	 else {echo "Information provided are not correct, please try again with correct information";}
 }
else {echo "Information provided are not correct, please try again with correct information";} 
}


 }


?>
    
          <html>
        <head>
        <script type="text/javascript" src="/js/jquery.js"></script>
        <script type="text/javascript" src="/js/jquery.validate.js"></script>
<script type="text/javascript" src="/js/jquery.pstrength-min.1.2.js"></script>

<script type="text/javascript">
            
$(function() {
$('.password').pstrength();
});

	  $(document).ready(function(){
    $("#form").validate({
  rules: {
    email: {
      required: true,
      email: true
    }
  }
});
  });

  </script>
  
  </head>
        <body>
  
         <fieldset> 
     <form action='' method='POST' id='form'>
    
        <p>Enter Your Email: </p>
        <p>
          
          <input type='text' name='email' class="required"></td>




        <p>Enter Your Temporary Password: </p>
        <p>
          
          <input type='text' name='currentpass' class="required"></td>
          
            <p>Enter Your New Password: </p>      <p>
          
          <input type='text' name='newpassword' class="password"></td>
          
          
                      <p>Repeat Your New Password: </p>      <p>
          
          <input type='text' name='repassword' class="required"></td>
          
          
          </table>
        </p>
       <p>
         <input type='submit' name='reset' value='Submit' id='form'>
       </form>
    </fieldset>
    
    </body>
    </html>






Link to comment
Share on other sites

first you check if GET, then you check if POST. it's probably one or the other, but not both. then, where does $row come from here?

 

if (isset($_POST['reset']) && $_POST['reset'])
{

$myemail=$row['email'];	 
$mycurrentpass=$row['currentpass'];
$mynewpass=$row['newpassword'];
$myrepass=$row['repassword'];

 

if you turn on all error_reporting, you'd get notices about undefined indexes, and the problem would be staring you right in the face.

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.