Jump to content

Undefind Function


mike177

Recommended Posts

Hi, have written my own login script and now I'm buliding a feature to edit your account information.

 

I have 90% of it completed but I am getting an error, Call to a undefined function in process.php on 86. I checked through the files and from what I can tell everythings okay. But my attempts to solve the issue have failed so I call on the forums.

 

Porcess.php

<?php
   function procEditAccount(){
      global $core, $error;
      /* Account edit attempt */
      $retval = $core->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);

      /* Account edit successful */
      if($retval){
         $_SESSION['useredit'] = true;
         header("Location: index.php");
      }
      /* Error found with form */
      else{
         $_SESSION['value_array'] = $_POST;
         $_SESSION['error_array'] = $error->getErrorArray();
         header("Location: accountedit.php");
      }
   }
?>

 

core.php

<?php
function editAccount($subcurpass, $subnewpass, $subemail){
      global $functions, $error;  //The database and form object
      /* New password entered */
      if($subnewpass){
         /* Current Password error checking */
         $field = "curpass";  //Use field name for current password
         if(!$subcurpass){
            $error->setError($field, "* Current Password not entered");
         }
         else{
            /* Check if password too short or is not alphanumeric */
            $subcurpass = stripslashes($subcurpass);
            if(strlen($subcurpass) < 4 ||
               !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){
               $error->setError($field, "* Current Password incorrect");
            }
            /* Password entered is incorrect */
            if($functions->confirmUserPass($this->email,md5($subcurpass)) != 0){
               $error->setError($field, "* Current Password incorrect");
            }
         }
         
         /* New Password error checking */
         $field = "newpass";  //Use field name for new password
         /* Spruce up password and check length*/
         $subpass = stripslashes($subnewpass);
         if(strlen($subnewpass) < 4){
            $error->setError($field, "* New Password too short");
         }
         /* Check if password is not alphanumeric */
         else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){
            $error->setError($field, "* New Password not alphanumeric");
         }
      }
      /* Change password attempted */
      else if($subcurpass){
         /* New Password error reporting */
         $field = "newpass";  //Use field name for new password
         $error->setError($field, "* New Password not entered");
      }
      
      /* Email error checking */
      $field = "email";  //Use field name for email
      if($subemail && strlen($subemail = trim($subemail)) > 0){
         /* Check if valid email address */
         $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
                 ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
                 ."\.([a-z]{2,}){1}$";
         if(!eregi($regex,$subemail)){
            $error->setError($field, "* Email invalid");
         }
         $subemail = stripslashes($subemail);
      }
      
      /* Errors exist, have user correct them */
      if($error->num_errors > 0){
         return false;  //Errors with form
      }
      
      /* Update password since there were no errors */
      if($subcurpass && $subnewpass){
         $functions->updateUserField($this->email,"password",md5($subnewpass));
      }
      
      /* Change Email */
      if($subemail){
         $functions->updateUserField($this->email,"email",$subemail);
      }
      
      /* Success! */
      return true;
   }
?>

Note that there is more to the files though it's not relevant.

 

Thanks in advance for any help.

Link to comment
Share on other sites

Can you post the code for line 76-86 in process.php?

	}
	/*error with form*/
	else if($retval == 1){
		$_SESSION['value_array'] = $_POST;
		$_SESSION['error_array'] = $error->getErrorArray();
		header("Location: register.php");
	}
	/*Registration Failed*/
	else if($retval == 2){
		$_SESSION['regsuccess'] = false;
		header("Location: http://mnielsen.awardspace.com");
	}
}
   function procEditAccount(){
      global $core, $error;
      /* Account edit attempt */
      $retval = $core->editAccount($_POST['curpass'], $_POST['newpass'], $_POST['email']);

Link to comment
Share on other sites

what version of PHP are you using, and where have you defined editAccount()? The function must be in the same file as the code that calls it or must be included in that file.

The lastest version, and its defined in process its erroring on the the line that starts the functions.

Link to comment
Share on other sites

You are trying to execute the function editAccount(), but the error is telling you that you haven't programmed that function anywhere. If its in another file, you need to include that file into this script.

All the files are inclduded. All form submits are sent to process which then sends them off the core which is the hart of the system, then if it needs to preform a operation on a database it selectes a functions from functions.php.

Link to comment
Share on other sites

Can you show us the function editAccount()

<?php
function editAccount($subcurpass, $subnewpass, $subemail){
      global $functions, $error;  //The database and form object
      /* New password entered */
      if($subnewpass){
         /* Current Password error checking */
         $field = "curpass";  //Use field name for current password
         if(!$subcurpass){
            $error->setError($field, "* Current Password not entered");
         }
         else{
            /* Check if password too short or is not alphanumeric */
            $subcurpass = stripslashes($subcurpass);
            if(strlen($subcurpass) < 4 ||
               !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){
               $error->setError($field, "* Current Password incorrect");
            }
            /* Password entered is incorrect */
            if($functions->confirmUserPass($this->email,md5($subcurpass)) != 0){
               $error->setError($field, "* Current Password incorrect");
            }
         }
         
         /* New Password error checking */
         $field = "newpass";  //Use field name for new password
         /* Spruce up password and check length*/
         $subpass = stripslashes($subnewpass);
         if(strlen($subnewpass) < 4){
            $error->setError($field, "* New Password too short");
         }
         /* Check if password is not alphanumeric */
         else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){
            $error->setError($field, "* New Password not alphanumeric");
         }
      }
      /* Change password attempted */
      else if($subcurpass){
         /* New Password error reporting */
         $field = "newpass";  //Use field name for new password
         $error->setError($field, "* New Password not entered");
      }
      
      /* Email error checking */
      $field = "email";  //Use field name for email
      if($subemail && strlen($subemail = trim($subemail)) > 0){
         /* Check if valid email address */
         $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"
                 ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"
                 ."\.([a-z]{2,}){1}$";
         if(!eregi($regex,$subemail)){
            $error->setError($field, "* Email invalid");
         }
         $subemail = stripslashes($subemail);
      }
      
      /* Errors exist, have user correct them */
      if($error->num_errors > 0){
         return false;  //Errors with form
      }
      
      /* Update password since there were no errors */
      if($subcurpass && $subnewpass){
         $functions->updateUserField($this->email,"password",md5($subnewpass));
      }
      
      /* Change Email */
      if($subemail){
         $functions->updateUserField($this->email,"email",$subemail);
      }
      
      /* Success! */
      return true;
   }
?>

Link to comment
Share on other sites

I gotta admit, I don't see the problem. The function has been defined and is included. Looks like it should work to me.

 

Are you sure $core is defined at that point? If not, that could be where your problem is - its calling on a function that won't exist $core has not been created. Thats about the only thing I can think of.

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.