onthespot Posted August 6, 2009 Share Posted August 6, 2009 Hey guys, In the edit account section of my site, there is the capacity to change the password. At the moment, the new password need be entered only once, however I am looking to make users confirm password. The code for editing (passward not confirmed) if($subnewpass){ $field = "curpass"; //Use field name for current password if(!$subcurpass){ $form->setError($field, "* Current Password not entered"); } else{ $subcurpass = stripslashes($subcurpass); if(strlen($subcurpass) < 6 || !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){ $form->setError($field, "* Current Password incorrect"); } if($database->confirmUserPass($this->username,md5($subcurpass)) != 0){ $form->setError($field, "* Current Password incorrect"); } } $field = "newpass"; //Use field name for new password $field2 = "newpass2"; //Use field name for new password $subpass = stripslashes($subnewpass); if(strlen($subnewpass) < 4){ $form->setError($field, "* New Password too short"); } else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){ $form->setError($field, "* New Password not alphanumeric"); } } else if($subcurpass){ /* New Password error reporting */ $field = "newpass"; //Use field name for new password $form->setError($field, "* New Password not entered"); } The code I am trying to get to work for the confirmation if($subnewpass){ $field = "curpass"; //Use field name for current password if(!$subcurpass){ $form->setError($field, "* Current Password not entered"); } else{ $subcurpass = stripslashes($subcurpass); if(strlen($subcurpass) < 6 || !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){ $form->setError($field, "* Current Password incorrect"); } if($database->confirmUserPass($this->username,md5($subcurpass)) != 0){ $form->setError($field, "* Current Password incorrect"); } } $field = "mewpass"; //Use field name for password $field2 = "newpass2"; // Second field for password if(!$subnewpass2){ $form->setError($field2, "* Password not entered"); } else{ $subnewpass = stripslashes($subnewpass); $subnewpass2 = stripslashes($subnewpass2); if($subnewpass !== $subnewpass2){ $form->setError($field, "* Passwords does not match"); } $subnewpass = stripslashes($subnewpass); if(strlen($subnewpass) < 6){ $form->setError($field, "* Password too short, must be 6 characters long"); } else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){ $form->setError($field, "* Password not alphanumeric"); } } Should this work? Quote Link to comment https://forums.phpfreaks.com/topic/169070-solved-editing-accounts/ Share on other sites More sharing options...
Bjom Posted August 6, 2009 Share Posted August 6, 2009 Shouldn't it? You're not assigning your $subcurpass and $subnewpass variables any values, other than that it looks ok. We cannot know what happens when you do that confirmUserPass thingy, but if that's working... (using prepared statements I hope...) Quote Link to comment https://forums.phpfreaks.com/topic/169070-solved-editing-accounts/#findComment-892058 Share on other sites More sharing options...
onthespot Posted August 6, 2009 Author Share Posted August 6, 2009 I altered it slightly a different way, I understand how it can be hard for you to understand with limited data. But its working no problem now, which is good Quote Link to comment https://forums.phpfreaks.com/topic/169070-solved-editing-accounts/#findComment-892064 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.