mike177 Posted February 2, 2008 Share Posted February 2, 2008 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 https://forums.phpfreaks.com/topic/89106-undefind-function/ Share on other sites More sharing options...
willpower Posted February 2, 2008 Share Posted February 2, 2008 line 86 is relevant tho, as i have no idea which one it is! Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-456381 Share on other sites More sharing options...
mike177 Posted February 3, 2008 Author Share Posted February 3, 2008 line 86 is relevant tho, as i have no idea which one it is! Yes line 86 is relevant, I never said it wasn't. I said that the remainder of the file isn't relevant. Also it would be the function line as it is called for though it error's undefined. Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-456595 Share on other sites More sharing options...
haku Posted February 3, 2008 Share Posted February 3, 2008 Can you post the code for line 76-86 in process.php? Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-456683 Share on other sites More sharing options...
mike177 Posted February 4, 2008 Author Share Posted February 4, 2008 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 https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-457308 Share on other sites More sharing options...
haku Posted February 4, 2008 Share Posted February 4, 2008 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. Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-457322 Share on other sites More sharing options...
willpower Posted February 4, 2008 Share Posted February 4, 2008 i love when you try to help someone and they come back with a curt remark! With respect i asked you to advise which line 86 was. Simple Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-457599 Share on other sites More sharing options...
haku Posted February 4, 2008 Share Posted February 4, 2008 Heh 'curt'. I think my grandma used to say that... Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-457602 Share on other sites More sharing options...
Guardian-Mage Posted February 4, 2008 Share Posted February 4, 2008 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. Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-457614 Share on other sites More sharing options...
mike177 Posted February 5, 2008 Author Share Posted February 5, 2008 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 https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458300 Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 Can you show us the function editAccount() Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458311 Share on other sites More sharing options...
mike177 Posted February 5, 2008 Author Share Posted February 5, 2008 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 https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458320 Share on other sites More sharing options...
mike177 Posted February 5, 2008 Author Share Posted February 5, 2008 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 https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458323 Share on other sites More sharing options...
mike177 Posted February 5, 2008 Author Share Posted February 5, 2008 Seens this issue isn't been resolved I attached the complete source code so you can look for yourselves and not have to wait for me. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458327 Share on other sites More sharing options...
mike177 Posted February 5, 2008 Author Share Posted February 5, 2008 i love when you try to help someone and they come back with a curt remark! With respect i asked you to advise which line 86 was. Simple I'm not one to fight so I will let our differences go over my head as if nothing happened. Link to comment https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458333 Share on other sites More sharing options...
haku Posted February 5, 2008 Share Posted February 5, 2008 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 https://forums.phpfreaks.com/topic/89106-undefind-function/#findComment-458371 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.