Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/169070-solved-editing-accounts/
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.